npm.io
0.2.6 • Published 9 years ago

1tree-json

Licence
MIT
Version
0.2.6
Deps
3
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

1tree-json

Allows conversion between JSON objects and 1tree instances

const JsonTree = require( '1tree-json' )

const jsonData = require( './test-data.json' )

const tree = JsonTree( jsonData )

const numbers = tree.findAll( node => node.isNumber() )

numbers.forEach( numberNode => {
  const value = node.value()

  value.nodeValue *= 2

  node.value( value )
})

const newData = tree.toJson()

console.log( JSON.stringify( newData, null, 2 ) )

Keywords