json
0.1.0Encode and decode JSON with Python's hooks and options.
edge add json && edge lock
sha256-055de97b4078ea30b1df7093e373c69d56e9e00ca6c79af1599156d3b87721b3
json
json is loads and dumps. loads takes the object_hook, object_pairs_hook, parse_float, parse_int and parse_constant callables. dumps takes indent, sort_keys, ensure_ascii, check_circular, allow_nan, skipkeys, default, separators and cls.
ada
{"k": [1, 2, 3], "ok": true}indent and sort_keys shape the output.
{
"a": [
true,
null
],
"b": 1
}Integers cross as 128-bit values, so a round trip keeps numbers past 64 bits, and a float that holds a whole number keeps its .0 so it comes back a float.
True 3.0 3.0
A parse failure raises json.JSONDecodeError, which is ValueError here, nesting past 1000 levels raises RuntimeError, and a value with no JSON form raises TypeError unless default turns it into one.
parse failed: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) dump failed: Object of type function is not JSON serializable