json
JSON encoding and decoding functions.
Members
decode
json.decode(x, default?)Decodes a JSON string into a Starlark value. JSON objects become dicts, arrays become lists.
Parameters
xstringJSON string to decodedefault?optionalanyValue to return if x cannot be decoded as JSON (optional)Returns
resultanyDecoded Starlark valueencode
json.encode(x)Encodes a Starlark value as a JSON string. Supports None, bool, int, float, string, dict, list, tuple, and structs.
Parameters
xanyValue to encode as JSONReturns
resultstringJSON-encoded stringindent
json.indent(s, prefix?, indent?)Returns the indented form of a JSON-encoded string.
Parameters
sstringJSON string to indentprefix?optionalstringPrefix for each line (default: empty)indent?optionalstringIndent string for each level (default: “\t”)Returns
resultstringIndented JSON string