1tree-json 中文文档教程
1tree-json
允许 JSON 对象和 1tree 实例之间的转换
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 ) )
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 ) )