Skip to content

json

Classes:

Attributes:

JSON_TYPES module-attribute

JSON_TYPES = (
    int,
    str,
    float,
    bool,
    type(None),
    dict,
    list,
    tuple,
)

The types that can be serialized to JSON.

json_serializer module-attribute

json_serializer = JsonSerializer()

JsonSerializer with default settings.

json_stream_serializer module-attribute

json_stream_serializer = JsonStreamSerializer()

JsonStreamSerializer with default settings.

JsonSerializer

JsonSerializer(
    encoder: JSONEncoder = DEFAULT_JSON_ENCODER,
    decoder: JSONDecoder = DEFAULT_JSON_DECODER,
)

Bases: Serializer[JsonType], _JsonSerializerBase

A serializer for JSON data.

Methods:

deserialize_config

deserialize_config(config: str) -> C

Deserialize the configuration from a JSON string.

deserialize_data

deserialize_data(content: SerializedData) -> JsonType

Deserialize the given JSON data.

serialize_config

serialize_config(config: C) -> str

Serialize the configuration to a JSON string.

serialize_data

serialize_data(value: JsonType) -> SerializedData

Serialize the given value to JSON.

JsonStreamSerializer

JsonStreamSerializer(
    encoder: JSONEncoder = DEFAULT_JSON_ENCODER,
    decoder: JSONDecoder = DEFAULT_JSON_DECODER,
)

Bases: StreamSerializer[JsonType], _JsonSerializerBase

A serializer for JSON data.

Methods:

deserialize_config

deserialize_config(config: str) -> C

Deserialize the configuration from a JSON string.

deserialize_data_stream

deserialize_data_stream(
    content: SerializedDataStream,
) -> AsyncGenerator[JsonType]

Deserialize the given stream of JSON data.

serialize_config

serialize_config(config: C) -> str

Serialize the configuration to a JSON string.

serialize_data_stream

serialize_data_stream(
    stream: AsyncIterable[JsonType],
) -> SerializedDataStream

Serialize the given stream of JSON data.