Skip to main content

TagUUID

This class provides a mechanism for serializing and deserializing UUID objects to and from JSON. It identifies UUID instances, converts them to their hexadecimal string representation for storage, and reconstructs the original UUID objects during decoding.

Attributes

AttributeTypeDescription
keystring = uThe unique tag identifier used during JSON serialization to distinguish UUID types.

Methods


check()

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

Checks if the provided value is an instance of a UUID object.

Parameters

NameTypeDescription
valuet.AnyThe object to be validated against the UUID type

Returns

TypeDescription
boolTrue if the value is a UUID instance, False otherwise

to_json()

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

Converts a UUID object into its hexadecimal string representation for JSON serialization.

Parameters

NameTypeDescription
valuet.AnyThe UUID instance to be serialized

Returns

TypeDescription
t.AnyA string containing the 32-character hexadecimal representation of the UUID

to_python()

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

Parses a hexadecimal string and reconstructs the corresponding UUID object.

Parameters

NameTypeDescription
valuet.AnyThe serialized value, typically a hexadecimal string, to be converted back into a UUID object

Returns

TypeDescription
t.AnyA new UUID instance initialized from the provided input value