Lazy JSON Files (xonsh.lazyjson)

Implements a lazy JSON file class that wraps around json data.

class xonsh.lazyjson.LJNode(offsets, sizes, root)[source]

A proxy node for JSON nodes. Acts as both sequence and mapping.

Parameters:

offsets : dict, list, or int

offsets of corresponding data structure, in bytes

sizes : dict, list, or int

sizes of corresponding data structure, in bytes

root : weakref.proxy of LazyJSON

weakref back to root node, which should be a LazyJSON object.

load()[source]

Returns the Python data structure represented by the node.

class xonsh.lazyjson.LazyJSON(f, reopen=True)[source]

Represents a lazy json file. Can be used like a normal Python dict or list.

Parameters:

f : file handle or str

JSON file to open.

reopen : bool, optional

Whether new file handle should be opened for each load.

close()[source]

Close the file handle, if appropriate.

xonsh.lazyjson.dumps(obj, sort_keys=False)[source]

Dumps an object to JSON with an index.

xonsh.lazyjson.index(obj, sort_keys=False)[source]

Creates an index for a JSON file.

xonsh.lazyjson.ljdump(obj, fp, sort_keys=False)[source]

Dumps an object to JSON file.