Every line of 'converting circular structure to json node js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
684 function toJSTree(node) { 685 return { 686 'name': printer(node), 687 'children': RUNTIME.ffi.toArray( 688 gf(node, "children")).map(toJSTree) // TODO: unsafe 689 }; 690 }
49 get json() { 50 var ports = []; 51 this.forEachPort( 52 port => ports.push(Port.fromJSON(port, { 53 graph: this.graph, 54 node: this 55 })) 56 ); 57 return { 58 id: this.id, 59 data: this.data, 60 bounds: this.bounds.toArray(), 61 layer: this.layer, 62 scale: this.scale, 63 ports 64 }; 65 }
9 function NodeWithoutCircularReferences(node) { 10 var newNode = {}; 11 Object.assign(newNode, node); 12 delete newNode.next; 13 delete newNode.prev; 14 delete newNode.parent; 15 if (isNodeArray(newNode.children)) { 16 newNode.children = removeCircularRefs(newNode.children); 17 } 18 return newNode; 19 }
122 function graphToJSON () { 123 var json = self.nodeToJSON() 124 json.nodes = [] 125 126 for (var i in _nodes) 127 json.nodes.push(_nodes[i].toJSON()) 128 129 return json 130 }
26 function stringify(obj, circularProperties) { 27 var stringified, 28 circularProperties = circularProperties ? circularProperties : []; 29 30 function removeCircular(name, value) { 31 if (-1 === circularProperties.indexOf(name)) { 32 return value; 33 } else { 34 //Undefined properties will be removed from JSON. 35 return undefined; 36 } 37 } 38 39 try { 40 if (0 === circularProperties.length) { 41 stringified = JSON.stringify(obj, null, 4); 42 } else { 43 stringified = JSON.stringify(obj, removeCircular, 4); 44 } 45 } catch (e) { 46 console.error('Stringify error:', e); 47 stringified = String(obj); 48 } 49 50 return stringified; 51 }
42 export function toJSON(npe: NodePathElement): NodePathElementJSON { 43 const result: NodePathElementJSON = { 44 node: Node.toJSON(npe.node), 45 index: npe.index, 46 children: npe.children.map(NodePathElement.toJSON), 47 }; 48 if (undefined !== npe.isMarked) 49 result.isMarked = npe.isMarked; 50 if (undefined !== npe.filteringData) 51 result.filteringData = nodePathFilteringDataToJson(npe.filteringData); 52 return result; 53 }
90 nonCircularStringify(data) { 91 var cache = []; 92 return JSON.stringify(data, function(key, value) { 93 if (typeof value === 'object' && value !== null) { 94 if (cache.indexOf(value) !== -1) { 95 // Circular reference found, discard key 96 return; 97 } 98 // Store value in our collection 99 cache.push(value); 100 } 101 return value; 102 }); 103 }
40 export function convertTreeToObject(objectToSerialize) { 41 return JSON.parse(JSON.stringify(objectToSerialize, replaceMapWithObject)); 42 }
136 function encode(object) { 137 return converter( 138 object, 139 encoders.concat(({ value }) => 140 Func.encode({ 141 value, 142 local_functions_map, 143 registerLocalFunction 144 }) 145 ) 146 ) 147 }