MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / isNestedJSON

Function isNestedJSON

frontend/src/hooks/stream/useStreamingJSONParser.ts:28–45  ·  view source on GitHub ↗
(json: any)

Source from the content-addressed store, hash-verified

26 * Determine if a JSON structure has nested objects/arrays
27 */
28 const isNestedJSON = (json: any): boolean => {
29 if (Array.isArray(json)) {
30 if (json.length === 0) return false;
31 const firstItem = json[0];
32 return typeof firstItem === 'object' && firstItem !== null && (
33 Object.values(firstItem).some(val =>
34 typeof val === 'object' && val !== null &&
35 (Array.isArray(val) || Object.keys(val).length > 0)
36 )
37 );
38 } else if (json && typeof json === 'object') {
39 return Object.values(json).some(val =>
40 typeof val === 'object' && val !== null &&
41 (Array.isArray(val) || Object.keys(val).length > 0)
42 );
43 }
44 return false;
45 };
46
47 /**
48 * Detect property types from JSON data

Callers 2

flattenJSONFunction · 0.85
parseJSONStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected