(json: any)
| 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 |
no outgoing calls
no test coverage detected