/** * JSON Utilities * Safe JSON operations with error handling and type support */ /** * Safely parse JSON with error handling * * @param json - JSON string to parse * @param fallback - Fallback value if parsing fails * @returns Parsed object or fallback * * @example * ```typescript * const data = safeParseJSON('{"name": "test"}', {}); * const invalid = safeParseJSON('invalid', null); // Returns null * ``` */ export declare function safeParseJSON(json: string, fallback: T): T; /** * Safely stringify object with error handling * * @param value - Value to stringify * @param fallback - Fallback string if stringify fails * @returns JSON string or fallback * * @example * ```typescript * const str = safeStringify({ name: 'test' }, '{}'); * const circular = safeStringify(circularObj, 'null'); // Returns 'null' * ``` */ export declare function safeStringify(value: T, fallback?: string): string; /** * Pretty print JSON with indentation * * @param value - Value to stringify * @param space - Number of spaces for indentation * @returns Formatted JSON string */ export declare function prettyStringify(value: T, space?: number): string; /** * Deep clone object using JSON (simple objects only) * * @param value - Value to clone * @returns Cloned value * * @example * ```typescript * const original = { name: 'test', data: [1, 2, 3] }; * const clone = jsonClone(original); * ``` */ export declare function jsonClone(value: T): T; /** * Check if string is valid JSON * * @param json - String to validate * @returns True if valid JSON */ export declare function isValidJSON(json: string): boolean; /** * Get JSON string size in bytes * * @param value - Value to measure * @returns Size in bytes */ export declare function getJSONSize(value: T): number; /** * Truncate JSON string to maximum length * * @param value - Value to stringify and truncate * @param maxLength - Maximum length of resulting string * @param suffix - Suffix to add when truncated * @returns Truncated JSON string * * @example * ```typescript * const data = { name: 'very long name', data: [...] }; * const short = truncateJSON(data, 50, '...[truncated]'); * ``` */ export declare function truncateJSON(value: T, maxLength: number, suffix?: string): string; /** * Compare two values by their JSON representation * * @param a - First value * @param b - Second value * @returns True if JSON representations are equal */ export declare function jsonEquals(a: T, b: T): boolean; /** * Remove circular references from object before JSON serialization * * @param obj - Object to clean * @returns Object safe for JSON.stringify */ export declare function removeCircularReferences(obj: T): T; //# sourceMappingURL=json.d.ts.map