UNPKG

xc-mcp

Version:

MCP server that wraps Xcode command-line tools for iOS/macOS development workflows

39 lines 1.27 kB
/** * JSON Parser Utility * * Handles flexible JSON parsing for formats that might be: * - JSON array: [{...}, {...}, {...}] (single line, standard JSON) * - NDJSON: {...}\n{...}\n{...} (newline-delimited JSON, one object per line) * * Why: Different tools return JSON in different formats. IDB returns JSON arrays, * while other tools might use NDJSON. This utility handles both transparently. */ /** * Parse JSON that might be in array or NDJSON format * * @param text Raw JSON text (array or NDJSON format) * @returns Array of parsed JSON objects * * @example * // JSON array format (IDB output) * parseFlexibleJson('[{"id":1},{"id":2}]') * // Returns: [{id:1}, {id:2}] * * @example * // NDJSON format * parseFlexibleJson('{"id":1}\n{"id":2}') * // Returns: [{id:1}, {id:2}] */ export declare function parseFlexibleJson(text: string): any[]; /** * Detect the JSON format of the input text * * @param text Raw JSON text * @returns 'array' | 'ndjson' | 'unknown' * * @example * detectJsonFormat('[{"id":1}]') // Returns: 'array' * detectJsonFormat('{"id":1}\n{"id":2}') // Returns: 'ndjson' */ export declare function detectJsonFormat(text: string): 'array' | 'ndjson' | 'single' | 'unknown'; //# sourceMappingURL=json-parser.d.ts.map