5.1.0 • Published 6 years ago

jsonolt v5.1.0

Weekly downloads
32
License
SEE LICENSE IN LI...
Repository
github
Last release
6 years ago

encode JSON data as ordered, labeled trees

JSON data is tree-like, but a lot of computer science literature on trees works on a slightly different formal structure: so-called "ordered, labeled trees" (OLTs). This package uniformly converts JSON-compatible data structures to and from slightly larger JSON-compatible structures that are easy to process as ordered, labeled trees.

Usage

var jsonolt = require('jsonolt')
var assert = require('assert')

var example = {
  a: 'x',
  b: null,
  c: [42]
}

assert.deepStrictEqual(
  jsonolt.encode(example),
  {
    path: [],
    label: {type: 'object'},
    children: [
      {
        path: ['a'],
        label: {type: 'key', value: 'a'},
        children: [
          {
            path: ['a'],
            label: {type: 'string', value: 'x'}
          }
        ]
      },
      {
        path: ['b'],
        label: {type: 'key', value: 'b'},
        children: [
          {
            path: ['b'],
            label: {type: 'null', value: null}
          }
        ]
      },
      {
        path: ['c'],
        label: {type: 'key', value: 'c'},
        children: [
          {
            path: ['c'],
            label: {type: 'array'},
            children: [
              {
                path: ['c', 0],
                label: {type: 'number', value: 42}
              }
            ]
          }
        ]
      }
    ]
  }
)

assert.deepEqual(
  jsonolt.decode(jsonolt.encode(example)),
  example
)

Licensing

This package is free to use in open source under the terms of Parity Public License.

Licenses for use in closed software are available via licensezero.com.

licensezero.com pricing

5.1.0

6 years ago

5.0.0

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago