trulens.core.utils.json¶
trulens.core.utils.json
¶
Json utilities and serialization utilities dealing with json.
Functions¶
obj_id_of_obj
¶
Create an id from a json-able structure/definition. Should produce the same name if definition stays the same.
json_str_of_obj
¶
Encode the given json object as a string.
json_default
¶
Produce a representation of an object which does not have a json serializer.
jsonify_for_ui
¶
jsonify_for_ui(*args, **kwargs)
Options for jsonify common to UI displays.
Redacts keys and hides special fields introduced by trulens.
jsonify
¶
jsonify(
obj: Any,
dicted: Optional[Dict[int, JSON]] = None,
instrument: Optional[Instrument] = None,
skip_specials: bool = False,
redact_keys: bool = False,
include_excluded: bool = True,
depth: int = 0,
max_depth: int = 256,
) -> JSON
Convert the given object into types that can be serialized in json.
Args:
obj: the object to jsonify.
dicted: the mapping from addresses of already jsonifed objects (via id)
to their json.
instrument: instrumentation functions for checking whether to recur into
components of `obj`.
skip_specials: remove specially keyed structures from the json. These
have keys that start with "__tru_".
redact_keys: redact secrets from the output. Secrets are detremined by
`keys.py:redact_value` .
include_excluded: include fields that are annotated to be excluded by
pydantic.
depth: the depth of the serialization of the given object relative to
the serialization of its container.
max_depth: the maximum depth of the serialization of the given object.
Objects to be serialized beyond this will be serialized as
"non-serialized object" as per
noserio`. Note that this may happen
for some data layouts like linked lists. This value should be no
larger than half the value set by
sys.setrecursionlimit.
Returns:
The jsonified version of the given object. Jsonified means that the the
object is either a JSON base type, a list, or a dict with the containing
elements of the same.