-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·48 lines (43 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
let travelJson = require('./lib/json-travel'),
checkCircular = require('./lib/json-check-circular'),
getValByKeyPath = require('./lib/json-get-val-by-keypath'),
treeify = require('./lib/json-treeify');
// exports
module.exports = {
/**
* get value of property in json obj
* eg: getValByKey({a:{b:{c:1}}}, "a.b.c") = 1
* @param json
* @param keyPath
* @param ownKeyCheck
* @returns {Array|*}
*/
getValByKeyPath, // 通过keyPath获取json的属性值
/**
* Recursive traversal of json obj
* @param {Object} json
* @param {Function} cb callback(key,val,curKeyPath,typeStr,isComplexObj,curDepth,isCircular) and context is parent obj
* @param {string} rootAlias
* @param {Boolean} safeMode default is true
* @returns {Array} keysArr
*/
travelJson,
/**
* convert a json obj to tree-like string
* @param {Object} json
* @param {Object} options
* {String} options.rootName
* {char|Number} options.space
* {Number} options.vSpace
* {Boolean} options.valueOut
* @returns {string|*} a tree-like string
*/
treeify,
treeString: treeify,
/**
* check circular obj
* @param obj
* @returns {Object} {{isCircular: boolean, circularProps: Array}}
*/
checkCircular
};