Skip to main content
Version: devel

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

View source on GitHub

custom_encode that hands every datetime to datetime_encoder

custom_pua_decode_nested

def custom_pua_decode_nested(obj: Any,
decoders: TPuaDecoders = DECODERS) -> Any

View source on GitHub

Decodes PUA markers in obj, recursing into dicts and lists in place.

custom_pua_remove

def custom_pua_remove(obj: Any) -> Any

View source on GitHub

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

View source on GitHub

Checks if bytes string contains pua marker

SupportsJson Objects

class SupportsJson(Protocol)

View source on GitHub

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

View source on GitHub

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

View source on GitHub

This is passed through to each SupportsJson implementation and mutates the global custom encoder.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.