/** * Utility functions for parsing JSON from LLM responses * LLMs sometimes include explanatory text before/after JSON * * @requires - No external dependencies (pure TypeScript utility) */ import { type JSONResult } from './json/result.js'; /** * Extract JSON from text that may contain additional content * Handles common patterns: * - "Here is the JSON: {...}" * - "```json\n{...}\n```" * - "{...}\n\nLet me explain..." * - Pure JSON */ export declare function extractJSON(text: string): string; /** * Parse JSON with robust error handling * Attempts to extract JSON from text if direct parsing fails * * @param text - The text to parse (may contain JSON within other content) * @returns Result containing parsed object, or error * * @example * ```typescript * const result = parseJSONResponse('{"name": "test"}') * if (result.ok) { * console.log(result.value.name) // "test" * } else { * console.error(result.error.message) * } * ``` */ export declare function parseJSONResponse(text: string): JSONResult; /** * Validate that the parsed result has expected structure * * @param data - The parsed data to validate * @param requiredFields - Array of required field names * @returns Result containing validated data, or error if structure is invalid * * @example * ```typescript * const result = validateJSONStructure(data, ['name', 'version']) * if (result.ok) { * console.log('Valid structure:', result.value) * } else { * console.error('Missing fields:', result.error.context.missingFields) * } * ``` */ export declare function validateJSONStructure(data: any, requiredFields: string[]): JSONResult; //# sourceMappingURL=jsonParser.d.ts.map