Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@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 43,015 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.