/** * JSON Parsing Utilities * * Utilities for serializing and deserializing JSON fields in database operations. * Handles the _json column pattern used for storing complex field types. */ import type { RevealDocument } from '../types/index.js'; /** * Parse a JSON field value safely * * @param value - Value to parse (may be string or already parsed object) * @returns Parsed value or original value if not JSON */ export declare function parseJsonField(value: unknown): unknown; /** * Deserialize JSON fields from database document * * Handles the _json column pattern: * - PostgreSQL JSONB returns as object * - SQLite TEXT returns as string * - Merges _json fields into document * - Removes _json column from result * - Deserializes other JSON strings (backwards compatibility) * * @param doc - Raw document from database * @param tableName - Table name (for logging) * @returns Deserialized document */ export declare function deserializeJsonFields(doc: Record, tableName?: string): RevealDocument; /** * Collect JSON fields into an object for the _json column * * @param data - Data object * @param jsonFieldNames - Set of field names that should be stored as JSON * @returns Object containing JSON fields */ export declare function collectJsonFields(data: Record, jsonFieldNames: Set): Record; /** * Serialize a value for database storage * * Converts objects and arrays to JSON strings for SQLite compatibility. * Primitives are returned as-is. * * @param value - Value to serialize * @returns Serialized value (string for objects/arrays, otherwise original value) */ export declare function serializeValueForDatabase(value: unknown): unknown; //# sourceMappingURL=json-parsing.d.ts.map