Skip to main content

PassDict

This class provides a mechanism for tagging dictionary values for JSON serialization. It validates that a value is a dictionary and recursively tags each value within the dictionary while maintaining the original string keys. This ensures that complex nested structures are properly processed for JSON output.

Attributes​

AttributeTypeDescription
tagcallable = to_jsonAn alias for the to_json method used to process dictionary values for JSON serialization.

Methods​


check()​

@classmethod
def check(
value: t.Any
) - > bool

Checks if the provided value is a dictionary instance.

Parameters​

NameTypeDescription
valuet.AnyThe object to be checked for dictionary type compatibility

Returns​

TypeDescription
boolTrue if the value is a dict, False otherwise

to_json()​

@classmethod
def to_json(
value: t.Any
) - > t.Any

Converts a dictionary into a JSON-serializable format by recursively tagging its values.

Parameters​

NameTypeDescription
valuet.AnyThe dictionary whose values need to be tagged for JSON serialization

Returns​

TypeDescription
t.AnyA new dictionary where all values have been processed by the serializer's tagging logic