hydra.json.writer module

JSON serialization functions using the Hydra AST.

hydra.json.writer.hex_byte(c: int) str

Encode a byte (0..255) as a two-character lowercase hex string. Non-byte inputs yield placeholder ‘?’ characters.

hydra.json.writer.json_string(s: str) str

Escape and quote a string for JSON output.

hydra.json.writer.key_value_to_expr(pair: tuple[str, Value]) Expr

Convert a key-value pair to an AST expression.

hydra.json.writer.print_json(value: Value) str

Serialize a JSON value to a string.

hydra.json.writer.value_to_expr(value: Value) Expr

Convert a JSON value to an AST expression for serialization.