PassDict
This class represents a dictionary type for JSON serialization. It checks if a given value is a dictionary and converts it into a JSON object where all values are tagged by the serializer.
Attributes
| Attribute | Type | Description |
|---|---|---|
| tag | method | This attribute is an alias for the 'to_json' method, which is used to convert a dictionary into a JSON-compatible format by serializing its values. |
Methods
check()
@classmethod
def check(
value: t.Any
) - > bool
Checks if the provided value is a dictionary. This method is used to validate if the input value is of the expected dictionary type.
Parameters
| Name | Type | Description |
|---|---|---|
| value | t.Any | The value to be checked for dictionary type. |
Returns
| Type | Description |
|---|---|
bool | True if the value is a dictionary, False otherwise. |
to_json()
@classmethod
def to_json(
value: t.Any
) - > t.Any
Converts a dictionary into a JSON-compatible format by tagging its values. This method ensures that all values within the dictionary are properly serialized for JSON output.
Parameters
| Name | Type | Description |
|---|---|---|
| value | t.Any | The dictionary to be converted to a JSON-compatible format. |
Returns
| Type | Description |
|---|---|
t.Any | A dictionary where each value has been tagged by the serializer, suitable for JSON serialization. |