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 string used to represent a UUID in serialized JSON format.

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 32-character hexadecimal string representing the UUID

to_python()

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

Parses a hexadecimal string or compatible input to reconstruct a Python UUID object.

Parameters

NameTypeDescription
valuet.AnyThe serialized representation of a UUID, typically a hexadecimal string

Returns

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