MCPcopy Create free account
hub / github.com/dot-agent/nextpy / serialize

Function serialize

nextpy/utils/serializers.py:63–80  ·  view source on GitHub ↗

Serialize the value to a JSON string. Args: value: The value to serialize. Returns: The serialized value, or None if a serializer is not found.

(value: Any)

Source from the content-addressed store, hash-verified

61
62
63def serialize(value: Any) -> SerializedType | None:
64 """Serialize the value to a JSON string.
65
66 Args:
67 value: The value to serialize.
68
69 Returns:
70 The serialized value, or None if a serializer is not found.
71 """
72 # Get the serializer for the type.
73 serializer = get_serializer(type(value))
74
75 # If there is no serializer, return None.
76 if serializer is None:
77 return None
78
79 # Serialize the value.
80 return serializer(value)
81
82
83def get_serializer(type_: Type) -> Serializer | None:

Callers 7

format_stateFunction · 0.90
_renderMethod · 0.90
serialize_mutable_proxyFunction · 0.90
test_serialize_imageFunction · 0.90
test_serialize_dataframeFunction · 0.90
test_serialize_plotlyFunction · 0.90

Calls 2

get_serializerFunction · 0.85
serializerFunction · 0.85

Tested by 4

test_serialize_imageFunction · 0.72
test_serialize_dataframeFunction · 0.72
test_serialize_plotlyFunction · 0.72