jangada.serialization.Serializable.deserialize#
- static Serializable.deserialize(data: Any) Any#
Recursively deserialize data to reconstruct objects.
Converts serialized dictionary structures back into Python objects. Handles nested Serializable objects, collections, and primitives.
- Parameters:
- dataAny
The serialized data to deserialize.
- Returns:
- Any
The reconstructed object: - dict with ‘__class__’ → Serializable instance - list → list (recursively deserialized) - dict without ‘__class__’ → dict (recursively deserialized) - Primitives → unchanged - None → None
- Raises:
- TypeError
If the data type is not supported for deserialization.
See also
serializeConvert objects to serializable data
Notes
If a class referenced in ‘__class__’ is not registered (not imported), deserialize creates a generic Serializable subclass on-the-fly with the necessary properties. This allows reading data even when the original class definition is unavailable.
Deserialization triggers all property parsers, observers, and post-initializers as if the object were being constructed normally.
Examples
Deserialize a simple object:
>>> class MyClass(Serializable): ... value = SerializableProperty(default=0) ... >>> qualname = get_full_qualified_name(MyClass) >>> data = {'__class__': qualname, 'value': 42} >>> obj = Serializable.deserialize(data) >>> obj.value 42
Roundtrip serialization:
>>> original = MyClass(value=99) >>> data = Serializable.serialize(original) >>> restored = Serializable.deserialize(data) >>> restored.value 99 >>> original == restored True
Collections are handled recursively:
>>> data = [1, 2, {'a': 3}] >>> result = Serializable.deserialize(data) >>> result [1, 2, {'a': 3}]
Unknown classes create generic Serializable objects:
>>> data = { ... '__class__': 'unknown.Module.UnknownClass', ... 'prop1': 42, ... 'prop2': "test" ... } >>> obj = Serializable.deserialize(data) >>> obj.prop1 42