endplay.parsers.json

Parser for endplay formatted JSON files

Classes:

JSONDecoder(*[, object_hook, parse_float, ...])

Class providing functionality for reading the JSON file format

JSONEncoder(*[, skipkeys, ensure_ascii, ...])

Class providing functionality for writing to the JSON file format

Functions:

dump(obj, fp, *[, skipkeys, ensure_ascii, ...])

dumps(obj, *[, skipkeys, ensure_ascii, ...])

load(fp, *[, object_hook, parse_float, ...])

loads(s, *[, object_hook, parse_float, ...])

class endplay.parsers.json.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)

Bases: JSONDecoder

Class providing functionality for reading the JSON file format

class endplay.parsers.json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: JSONEncoder

Class providing functionality for writing to the JSON file format

Methods:

default(o)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

iterencode(o[, _one_shot])

Encode the given object and yield each string representation as available.

default(o)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
iterencode(o, _one_shot=False)

Encode the given object and yield each string representation as available.

For example:

for chunk in JSONEncoder().iterencode(bigobject):
    mysocket.write(chunk)
endplay.parsers.json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, default=None, sort_keys=False, **kw)
endplay.parsers.json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, default=None, sort_keys=False, **kw)
endplay.parsers.json.load(fp, *, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
endplay.parsers.json.loads(s, *, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)