import { HsonNode } from "../../../core/types.js"; import { JsonValue } from "../../../core/types.js"; /** * Serialize a well-formed Hson tree to JSON text. * * Pipeline: * 1. Clone & validate: * - `clone_node($node)` creates a defensive copy so the original IR is not * mutated by any downstream fixes or assertions. * - `assert_invariants(clone, "serialize_json")` guarantees the node * satisfies all structural invariants expected of Hson 2.0 before * attempting to emit JSON. * * 2. Structural conversion: * - Projects the Hson tree into an internal ordered JSON representation, * resolving: * - VSNs (`_hson_root`, `_hson_obj`, `_hson_arr`, `_hson_elem`, `_hson_ii`, `_hson_str`, `_hson_val`) * - Standard tags (HTML-like and user-defined) * into standard JS shapes. * * - Object properties remain explicit entry sequences from the canonical * graph through emission; they never cross a plain JavaScript object. * * 3. Stringification: * - Uses the ordered JSON emitter so object-property order remains exact * and negative zero retains the valid JSON spelling `-0`. * * 4. Error handling: * - Any failure during the stringify step is caught and wrapped in * `_throw_transform_err` with a clear origin `"serialize-json"`. * * Guarantees: * - Input must be a valid `HsonNode` that passes invariants, or an error is * thrown. * - Output is a JSON string representing the same logical data that produced * the Hson tree (modulo the established Hson-to-JSON mapping rules). * * @param $node - The root Hson node to serialize. * @returns A JSON string representation of the node. * @throws If invariants fail or final JSON emission fails. */ export declare function serialize_json($node: HsonNode): string; /** * Serialize the JSON projection without collapsing IEEE-754 negative zero. * * `JSON.stringify(-0)` emits `0`, even though `-0` is a valid JSON numeric * spelling and canonical Hson graph equality distinguishes the two runtime * values. The transport therefore owns its numeric emission rather than * delegating numbers to `JSON.stringify`. */ export declare function serialize_json_value(value: JsonValue, depth?: number): string; /** Project a canonical Hson graph directly to its in-memory JSON value. */ export declare function json_value_from_node($node: HsonNode): JsonValue; //# sourceMappingURL=serialize-json.d.ts.map