typelets.django.json

Typing useful for working with Django’s JSON serialization.

Added in version 1.0.

Module Attributes

SerializableDjangoJSONValue

A type indicating a valid value that can be serialized to JSON.

SerializableDjangoJSONDict

A type for a dictionary mapping strings to JSON-serializable values.

SerializableDjangoJSONDictImmutable

An immutable type mapping strings to JSON-serializable values.

SerializableDjangoJSONList

A type for a list of JSON-serializable values.

SerializableDjangoJSONListImmutable

An immutable type of a list of JSON-serializable values.

typelets.django.json.SerializableDjangoJSONValue

A type indicating a valid value that can be serialized to JSON.

These values are all supported in DjbletsJSONEncoder.

Added in version 4.0.

alias of BaseSerializableJSONDict[_T] | BaseSerializableJSONList[_T] | BaseSerializableJSONDictImmutable[_T] | BaseSerializableJSONListImmutable[_T] | JSONDict | JSONDictImmutable | JSONList | JSONListImmutable | None | bool | float | int | str | Decimal | StrPromise | UUID | date | datetime | time | timedelta

typelets.django.json.SerializableDjangoJSONDict

A type for a dictionary mapping strings to JSON-serializable values.

These values are all supported in DjbletsJSONEncoder.

Added in version 4.0.

alias of Dict[str, BaseSerializableJSONDict[_T] | BaseSerializableJSONList[_T] | BaseSerializableJSONDictImmutable[_T] | BaseSerializableJSONListImmutable[_T] | JSONDict | JSONDictImmutable | JSONList | JSONListImmutable | None | bool | float | int | str | Decimal | StrPromise | UUID | date | datetime | time | timedelta]

typelets.django.json.SerializableDjangoJSONDictImmutable

An immutable type mapping strings to JSON-serializable values.

This is an immutable version of SerializableJSONDict, which cannot be modified once set. It can help with type narrowing and is recommended when returning data from a function that should not be changed.

These values are all supported in DjbletsJSONEncoder.

Added in version 4.0.

alias of Mapping[str, BaseSerializableJSONDict[_T] | BaseSerializableJSONList[_T] | BaseSerializableJSONDictImmutable[_T] | BaseSerializableJSONListImmutable[_T] | JSONDict | JSONDictImmutable | JSONList | JSONListImmutable | None | bool | float | int | str | Decimal | StrPromise | UUID | date | datetime | time | timedelta]

typelets.django.json.SerializableDjangoJSONList

A type for a list of JSON-serializable values.

These values are all supported in DjbletsJSONEncoder.

Added in version 4.0.

alias of List[BaseSerializableJSONDict[_T] | BaseSerializableJSONList[_T] | BaseSerializableJSONDictImmutable[_T] | BaseSerializableJSONListImmutable[_T] | JSONDict | JSONDictImmutable | JSONList | JSONListImmutable | None | bool | float | int | str | Decimal | StrPromise | UUID | date | datetime | time | timedelta]

typelets.django.json.SerializableDjangoJSONListImmutable

An immutable type of a list of JSON-serializable values.

This is an immutable version of SerializableJSONList, which cannot be modified once set. It can help with type narrowing and is recommended when returning data from a function that should not be changed.

These values are all supported in DjbletsJSONEncoder.

Added in version 4.0.

alias of Sequence[BaseSerializableJSONDict[_T] | BaseSerializableJSONList[_T] | BaseSerializableJSONDictImmutable[_T] | BaseSerializableJSONListImmutable[_T] | JSONDict | JSONDictImmutable | JSONList | JSONListImmutable | None | bool | float | int | str | Decimal | StrPromise | UUID | date | datetime | time | timedelta]