
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@ipld/dag-json
Advanced tools
You probably don't want to use this library directly and instead access it through the Block interface.
Usage:
const Block = require('@ipld/block')
const CID = require('cids')
const obj = {
x: 1,
/* CID instances are encoded as links */
y: [2, 3, new CID('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')],
z: {
a: new CID('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'),
b: null,
c: 'string'
}
}
let encoder = Block.encoder(obj, 'dag-json')
let encoded = await Block.encode() // binary encoded block
let decoded = await Block.decoder(encoded, 'dag-json').decode()
decoded.y[0] // 2
CID.isCID(decoded.z.a) // true
The dag-json
spec is quite simple.
Nodes are in standard JSON format with the following requirements:
{"x":1,"y":[2,3]}
'/'
value of the
base58 encoded CID.
{"/": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}
That's all :)
This library exposes an interface conforming to @ipld/codec-interface
.
FAQs
JS implementation of DAG-JSON
The npm package @ipld/dag-json receives a total of 53,349 weekly downloads. As such, @ipld/dag-json popularity was classified as popular.
We found that @ipld/dag-json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.