JSON Utilities
Module: polygraphy.json
- to_json(obj)[source]
Encode an object to JSON.
NOTE: For Polygraphy objects, you should use the
to_json()
method instead.- Returns:
A JSON representation of the object.
- Return type:
str
- from_json(src)[source]
Decode a JSON string to an object.
NOTE: For Polygraphy objects, you should use the
from_json()
method instead.- Parameters:
src (str) – The JSON representation of the object
- Returns:
The decoded instance
- Return type:
object
- save_json(obj, dest, description=None)[source]
Encode an object as JSON and save it to a file.
NOTE: For Polygraphy objects, you should use the
save()
method instead.- Parameters:
obj – The object to save.
src (Union[str, file-like]) – The path or file-like object to save to.
- load_json(src, description=None)[source]
Loads a file and decodes the JSON contents.
NOTE: For Polygraphy objects, you should use the
load()
method instead.- Parameters:
src (Union[str, file-like]) – The path or file-like object to load from.
- Returns:
The object, or None if nothing could be read.
- Return type:
object