hydra.json.decode module

JSON decoding for Hydra terms. Converts JSON Values to Terms using Either for error handling.

hydra.json.decode.decode_float(ft: FloatType, value: Value) object

Decode a JSON value to a float term. Finite values arrive as JSON numbers; NaN/Inf/-0.0 arrive as JSON string sentinels. Float32 and Float64 are symmetric.

hydra.json.decode.decode_integer(it: IntegerType, value: Value) object

Decode a JSON value to an integer term. Small ints from numbers; large ints from strings.

hydra.json.decode.decode_literal(lt: LiteralType, value: Value) object

Decode a JSON value to a literal term.

hydra.json.decode.expect_array(value: Value) object

Extract an array from a JSON value.

hydra.json.decode.expect_number(value: Value) object

Extract a number from a JSON value.

hydra.json.decode.expect_object(value: Value) object

Extract an object from a JSON value as a name-keyed map. Field order is not preserved here; decoding looks fields up by name.

hydra.json.decode.expect_string(value: Value) object

Extract a string from a JSON value.

hydra.json.decode.from_json(types: Mapping[Name, Type], compact_maps: bool, tname: Name, typ: Type, value: Value) object

Decode a JSON value to a Hydra term given a type and type name. Returns Left for type mismatches. The compactMaps flag mirrors toJson’s: it must be False for any caller reading the checked-in dist/json module-bootstrapping representation, since a byte-stable published-host decoder must be able to read that data unmodified.

hydra.json.decode.parse_special_float(s: str) object

Parse an IEEE sentinel string (NaN, Infinity, -Infinity, -0.0) to a float64. Returns Nothing for unrecognized strings.

hydra.json.decode.parse_special_float32(s: str) object

Parse an IEEE sentinel string (NaN, Infinity, -Infinity, -0.0) to a float32. Returns Nothing for unrecognized strings.