class documentation

Pydantic JSON payload converter.

Supports conversion of all types supported by Pydantic to and from JSON.

In addition to Pydantic models, these include all json.dump-able types, various non-json.dump-able standard library types such as dataclasses, types from the datetime module, sets, UUID, etc, and custom types composed of any of these.

Pickling preserves the cache size limit but excludes cached type adapters.

See https://docs.pydantic.dev/latest/api/standard_library_types/

Method __getstate__ Pickle without the type adapter cache, whose wrapper is not picklable.
Method __init__ Create a new payload converter.
Method __setstate__ Restore state with an empty type adapter cache.
Method from_payload See base class.
Method to_payload See base class.
Property encoding See base class.
Instance Variable _schema_serializer Undocumented
Instance Variable _to_json_options Undocumented
Instance Variable _type_adapter Undocumented
def __getstate__(self) -> dict[str, Any]: (source)

Pickle without the type adapter cache, whose wrapper is not picklable.

def __init__(self, to_json_options: ToJsonOptions | None = None, *, max_cached_type_adapters: int | None = 1024): (source)

Create a new payload converter.

Parameters
to_json_options:ToJsonOptions | NoneOptions for serializing values to JSON.
max_cached_type_adapters:int | NoneMaximum number of type adapters to cache, with least-recently-used eviction. Defaults to 1024. If None, the cache is unbounded. If zero, caching is disabled.
def __setstate__(self, state: dict[str, Any]): (source)

Restore state with an empty type adapter cache.

def from_payload(self, payload: temporalio.api.common.v1.Payload, type_hint: type | None = None) -> Any: (source)

See base class.

Uses pydantic.TypeAdapter.validate_json to construct an instance of the type specified by type_hint from the JSON payload. Type adapters are cached per hashable type hint; see max_cached_type_adapters on the constructor.

See https://docs.pydantic.dev/latest/api/type_adapter/#pydantic.type_adapter.TypeAdapter.validate_json.

def to_payload(self, value: Any) -> temporalio.api.common.v1.Payload | None: (source)

See base class.

Uses pydantic_core.to_json to serialize value to JSON.

See https://docs.pydantic.dev/latest/api/pydantic_core/#pydantic_core.to_json.

_schema_serializer = (source)

Undocumented

_to_json_options = (source)

Undocumented

_type_adapter = (source)

Undocumented