cddl

CDDL Test

Concise data definition language (RFC 8610) implementation and JSON validator in Node.js.

CDDL expresses Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.

There are also CDDL parser for other languages:

Note: this is work in progress, feel free to have a look at the code or contribute but don’t use this for anything yet!

Install

To install this package run:

$ npm install cddl

Using this package

Currently you can use this package to parse a CDDL file into an abstract syntax tree (AST). For example, given the following CDDL file:

person = {
    identity,       ; an identity
    employer: tstr, ; some employer
}

You can use this package to parse the file into an abstract syntax tree (AST):

const CDDL = require('cddl')

const ast = CDDL.parse('./spec.cddl')
console.log(ast)
/**
 * outputs:
 * [
 *   {
 *     Type: 'group',
 *     Name: 'person',
 *     Properties: [ [Object], [Object] ],
 *     IsChoiceAddition: false
 *   }
 * ]
 */

If you are interested in this project, please feel free to contribute ideas or code patches. Have a look into our contributing guidelines to get started.