DataAdapter
javascript DataAdapter
Npm
npm install json-array-adapter --save
Use
let DataAdapter = ;let data = a: b: c: 1 f: 6 e: 5 d: 4 'kong';console//{ b: { c: 1, f: 6 }, e: 5 }console//{ c: 1, f: 6 }console//kongconsole//6console//konglet v1 = DataAdaptersource a: b: c: 1 f: 6 e: 5 d: 4 'kong'; let v2 = DataAdaptersourcea:1b:1c:1a:1b:2c:2;console;//[ { a: 1, b: 2, c: 2 } ] let v3 = DataAdaptersource a: b: c: 1 f: 6 g: h:7 e: 5 d: 4;v3console//{"a":{"b":{"c":2,"f":6,"g":[{"h":8}]},"e":3},"d":5}//深合并consolelet res = v3console//{"a":{"b":{"c":4,"f":6,"g":[{"h":8,"i":[{"j":2}]}]},"e":4},"d":11}let res2 = v3console//{"a":{"b":{"c":4},"e":4},"d":11}
merge(target,changeOriginal=true, isDeep = true)
/**
* 树与树的合并
* isDeep,是否深层合并,以左侧数据结构为基础。
* changeOriginal是否对原数据直接修改
* */