Skip to main content

jsonify

Transform object making it suitable for json serialization.

def jsonify(
obj: Any,
builtin_types: tuple = (numbers.Real, str),
key: string = null,
keyfilter: callable = null,
unknown_type_filter: callable = null
) - > Any

Transform object making it suitable for json serialization.

Parameters

NameTypeDescription
objAnyThe source object to be transformed into a JSON-serializable format.
builtin_typestuple = (numbers.Real, str)A tuple of types that should be returned as-is without further transformation.
keystring = nullThe dictionary key associated with the current object, used primarily for error reporting in nested structures.
keyfiltercallable = nullA predicate function used to determine which dictionary keys should be included in the output.
unknown_type_filtercallable = nullA fallback function to handle types not explicitly supported; if null, unsupported types will raise a ValueError.

Returns

TypeDescription
AnyA JSON-compatible representation of the input object, where complex types like dates and custom objects are converted to strings or dictionaries.