Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipld/dag-json

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/dag-json

JSON Directed Acrylic Graph for IPLD

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50K
decreased by-3.9%
Maintainers
3
Weekly downloads
 
Created
Source

JSON Directed Acrylic Graph for IPLD

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

Spec

The dag-json spec is quite simple.

Nodes are in standard JSON format with the following requirements:

  • Objects are consistent and deterministic
    • Object keys are sorted (TODO: specify sorting algorithm).
    • No whitespace outside of values. {"x":1,"y":[2,3]}
  • Links are encoded as objects with a single '/' value of the base58 encoded CID.
    • {"/": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}

That's all :)

API

This library exposes an interface conforming to @ipld/codec-interface.

FAQs

Package last updated on 19 May 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc