MCPcopy Index your code
hub / github.com/loggerhead/json4u / toJSON

Method toJSON

src/lib/parser/tree.ts:349–363  ·  view source on GitHub ↗
(node = this.root())

Source from the content-addressed store, hash-verified

347 }
348
349 toJSON(node = this.root()): string | number | boolean | object | any[] | null {
350 if (!isIterable(node)) {
351 return node.value;
352 }
353
354 if (node.type === "object") {
355 const obj: Record<string, unknown> = {};
356 this.mapChildren(node, (node, key, i) => {
357 obj[key] = this.toJSON(node);
358 });
359 return obj;
360 } else {
361 return this.mapChildren(node, (node) => this.toJSON(node));
362 }
363 }
364}
365
366/**

Callers 2

jsonPathFunction · 0.80
expectEqFunction · 0.80

Calls 3

rootMethod · 0.95
mapChildrenMethod · 0.95
isIterableFunction · 0.90

Tested by 1

expectEqFunction · 0.64