MCPcopy Index your code
hub / github.com/triggerdotdev/jsonhero-web / generateChildren

Function generateChildren

app/utilities/jsonColumnView.ts:21–62  ·  view source on GitHub ↗
(
  info: JSONValueType,
  path: JSONHeroPath
)

Source from the content-addressed store, hash-verified

19}
20
21function generateChildren(
22 info: JSONValueType,
23 path: JSONHeroPath
24): Array<ColumnViewNode> {
25 if (info.name === "array" && info.value) {
26 return info.value.map((value, index) => {
27 const childPath = path.child(index.toString());
28 const childInfo = inferType(value);
29 const children = generateChildren(childInfo, childPath);
30
31 return {
32 id: childPath.toString(),
33 name: index.toString(),
34 title: index.toString(),
35 longTitle: `Index ${index.toString()}`,
36 subtitle: formatValue(childInfo),
37 icon: iconForType(childInfo),
38 children,
39 };
40 });
41 }
42
43 if (info.name === "object" && info.value) {
44 return Object.entries(info.value).map(([key, value]) => {
45 const cleanKey = key.replace(/\./g, "\\.");
46 const childPath = path.child(cleanKey);
47 const childInfo = inferType(value);
48 const children = generateChildren(childInfo, childPath);
49
50 return {
51 id: childPath.toString(),
52 name: key,
53 title: key,
54 subtitle: formatValue(childInfo),
55 icon: iconForType(childInfo),
56 children,
57 };
58 });
59 }
60
61 return [];
62}
63
64export function generateNodesToPath(
65 json: unknown,

Callers 1

generateColumnViewNodeFunction · 0.70

Calls 2

formatValueFunction · 0.90
iconForTypeFunction · 0.90

Tested by

no test coverage detected