class PydanticJSONPlainPayloadConverter(EncodingPayloadConverter): (source)
Constructor: PydanticJSONPlainPayloadConverter(to_json_options, max_cached_type_adapters)
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 |
See base class. |
| Method | to |
See base class. |
| Property | encoding |
See base class. |
| Instance Variable | _schema |
Undocumented |
| Instance Variable | _to |
Undocumented |
| Instance Variable | _type |
Undocumented |
ToJsonOptions | None = None, *, max_cached_type_adapters: int | None = 1024):
(source)
¶
Create a new payload converter.
| Parameters | |
toToJsonOptions | None | Options for serializing values to JSON. |
maxint | None | Maximum 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. |
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.
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.