dlt.common.json
JsonSerializable
Type representing a JSON-serializable object.
JsonEncoder
A callable that takes an object and returns a JSON-serializable representation of it.
Should raise TypeError if the object cannot be serialized.
DatetimeEncoder
A callable that renders a datetime for JSON instead of isoformat.
custom_encode_datetimes
def custom_encode_datetimes(datetime_encoder: DatetimeEncoder) -> JsonEncoder
custom_encode that hands every datetime to datetime_encoder
custom_pua_decode_nested
def custom_pua_decode_nested(obj: Any,
decoders: TPuaDecoders = DECODERS) -> Any
Decodes PUA markers in obj, recursing into dicts and lists in place.
custom_pua_remove
def custom_pua_remove(obj: Any) -> Any
Removes the PUA data type marker and leaves the correctly serialized type representation. Unmarked values are returned as-is.
may_have_pua
def may_have_pua(line: bytes) -> bool
Checks if bytes string contains pua marker
SupportsJson Objects
class SupportsJson(Protocol)
Minimum adapter for different json parser implementations
dumps
def dumps(obj: Any,
sort_keys: bool = False,
pretty: bool = False,
utc_z: bool = False,
datetime_encoder: Optional[DatetimeEncoder] = None) -> str
utc_z renders a UTC datetime with Z where the backend supports it, the pre-1.29 form.
datetime_encoder renders every datetime instead of isoformat.
set_custom_encoder_impl
def set_custom_encoder_impl(encoder: JsonEncoder) -> None
This is passed through to each SupportsJson implementation and mutates the global custom encoder.