Members
decode
"null","true"and"false"are parsed asNone,True, andFalse.* Numbers are parsed as int, or as a float if they contain a decimal point or an exponent. Although JSON has no syntax for non-finite values, very large values may be decoded as infinity.* a JSON object is parsed as a new unfrozen Starlark dict. If the same key string occurs more than once in the object, the last value for the key is kept.* a JSON array is parsed as new unfrozen Starlark list.
x is not a valid JSON encoding and the optional default parameter is specified (including specified as None), this function returns the default value.
If x is not a valid JSON encoding and the optional default parameter is not specified, this function fails.
Parameters
| Parameter | Description |
|---|---|
x | string; required JSON string to decode. |
default | default is unbound If specified, the value to return when x cannot be decoded. |
encode
- None, True, and False are converted to ‘null’, ‘true’, and ‘false’, respectively.* An int, no matter how large, is encoded as a decimal integer. Some decoders may not be able to decode very large integers.* A float is encoded using a decimal point or an exponent or both, even if its numeric value is an integer. It is an error to encode a non-finite floating-point value.* A string value is encoded as a JSON string literal that denotes the value. Each unpaired surrogate is replaced by U+FFFD.* A dict is encoded as a JSON object, in lexicographical key order. It is an error if any key is not a string.* A list or tuple is encoded as a JSON array.* A struct-like value is encoded as a JSON object, in field name order.
Parameters
| Parameter | Description |
|---|---|
x | required |
encode_indent
json.indent(json.encode(x), ...). See indent for description of formatting parameters.