/** * JSON Utilities using secure-json-parse * * Simplified JSON utilities that directly use secure-json-parse for security * against JSON injection and prototype pollution attacks. */ import { parse } from 'secure-json-parse'; /** * Safe JSON parsing using secure-json-parse * @param jsonString - JSON string to parse * @param maxSize - Maximum string size in bytes (default: 10MB) * @param fallback - Fallback value if parsing fails (default: null) * @returns Parsed object or fallback value */ export declare function safeJSONParse(jsonString: string, maxSize?: number, fallback?: T | null): T | null; /** * Safe JSON stringify with error handling and size limits * @param obj - Object to stringify * @param maxSize - Maximum string size in bytes (default: 10MB) * @param fallback - Fallback value if stringifying fails (default: '{}') * @returns JSON string or fallback value */ export declare function safeJSONStringify(obj: any, maxSize?: number, fallback?: string): string; /** * JSON stringification with size validation * @param obj - Object to stringify * @param maxSize - Maximum string size in bytes (default: 10MB) * @returns JSON string */ export declare function safeJSONStringifyWithSize(obj: any, maxSize?: number): string; /** * Truncate JSON string to specified length * @param jsonString - JSON string to truncate * @param maxLength - Maximum length (default: 500) * @returns Truncated JSON string */ export declare function truncateJSON(jsonString: string, maxLength?: number): string; /** * Deep clone object using secure-json-parse with size limits * @param obj - Object to clone * @param maxSize - Maximum JSON string size (default: 10MB) * @returns Cloned object or null if failed */ export declare function safeJSONClone(obj: any, maxSize?: number): T | null; /** * Compare two objects using JSON with error handling * @param obj1 - First object * @param obj2 - Second object * @returns True if objects are equal, false otherwise */ export declare function safeJSONEquals(obj1: any, obj2: any): boolean; /** * Extract specific fields from large JSON object * @param obj - Source object * @param fields - Array of field names to extract * @returns Object with only specified fields */ export declare function extractJSONFields(obj: any, fields: string[]): any; /** * Validate JSON structure against expected schema using secure-json-parse * @param jsonString - JSON string to validate * @param schema - Simple schema definition * @returns Validation result */ export declare function validateJSONStructure(jsonString: string, schema: { required?: string[]; optional?: string[]; maxSize?: number; }): { valid: boolean; errors: string[]; data?: any; }; /** * Async JSON parse with size validation using secure-json-parse * @param jsonString - JSON string to parse * @param maxSize - Maximum size in bytes (default: 10MB) * @returns Promise that resolves to parsed object */ export declare function safeJSONParseAsync(jsonString: string, maxSize?: number): Promise; /** * Async JSON stringify with size validation * @param obj - Object to stringify * @param maxSize - Maximum size in bytes (default: 10MB) * @param replacer - JSON replacer function (optional) * @param space - JSON space argument (optional) * @returns Promise that resolves to JSON string */ export declare function safeJSONStringifyAsync(obj: any, maxSize?: number, replacer?: (key: string, value: any) => any, space?: string | number): Promise; /** * Batch JSON operations for processing multiple items efficiently * @param items - Array of items to process * @param processor - Function to process each item * @param batchSize - Size of each batch (default: 10) * @param concurrency - Maximum concurrent batches (default: 3) * @returns Promise that resolves to array of processed results */ export declare function batchJSONOperation(items: T[], processor: (item: T) => Promise, batchSize?: number, concurrency?: number): Promise; export { parse as secureParse }; declare const _default: { safeJSONParse: typeof safeJSONParse; safeJSONStringify: typeof safeJSONStringify; safeJSONStringifyWithSize: typeof safeJSONStringifyWithSize; truncateJSON: typeof truncateJSON; safeJSONClone: typeof safeJSONClone; safeJSONEquals: typeof safeJSONEquals; extractJSONFields: typeof extractJSONFields; validateJSONStructure: typeof validateJSONStructure; safeJSONParseAsync: typeof safeJSONParseAsync; safeJSONStringifyAsync: typeof safeJSONStringifyAsync; batchJSONOperation: typeof batchJSONOperation; }; export default _default; //# sourceMappingURL=jsonUtils.d.ts.map