hydra.extract.json module

Utilities for extracting values from JSON objects.

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

Extract an array from a JSON value, failing if the value is not an array.

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

Extract a number from a JSON value, failing if the value is not a number.

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

Extract an object from a JSON value as a name-keyed map, failing if the value is not an object. Field order is not preserved; lookups are by name.

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

Extract a string from a JSON value, failing if the value is not a string.

hydra.extract.json.opt(fname: T0, m: Mapping[T0, T1]) object

Look up an optional field in a JSON object.

hydra.extract.json.opt_array(fname: T0, m: Mapping[T0, Value]) object

Look up an optional array field in a JSON object.

hydra.extract.json.opt_string(fname: T0, m: Mapping[T0, Value]) object

Look up an optional string field in a JSON object.

hydra.extract.json.require(fname: str, m: Mapping[str, T0]) object

Look up a required field in a JSON object, failing if not found.

hydra.extract.json.require_array(fname: str, m: Mapping[str, Value]) object

Look up a required array field in a JSON object.

hydra.extract.json.require_number(fname: str, m: Mapping[str, Value]) object

Look up a required number field in a JSON object.

hydra.extract.json.require_string(fname: str, m: Mapping[str, Value]) object

Look up a required string field in a JSON object.

hydra.extract.json.show_value(value: Value) str

Show a JSON value as a string.