yasoo

raw JSON →
0.12.6 verified Fri May 01 auth: no python

yasoo is a Python object serialization library (Yet Another Serializer Of Objects) that provides declarative serialization and deserialization for Python objects, with support for nested structures, type coercion, and custom serializers. Current version 0.12.6, requires Python >=3.6. Development appears low-cadence, with last release in 2021.

pip install yasoo
error AttributeError: module 'yasoo' has no attribute 'Serializer'
cause Incorrect import path; attempted `import yasoo` and then `yasoo.Serializer`.
fix
Use from yasoo import Serializer
error KeyError: 'name'
cause Deserializing from a list of dicts without using `many=True`.
fix
Use UserSerializer.deserialize(data, many=True) for lists.
gotcha Deserialization does not raise errors on extra keys by default; extra keys are silently ignored.
fix Use `raise_on_unknown=True` in the Serializer class Meta or when calling deserialize.
gotcha Serialized output is a plain dict, not JSON. You must call json.dumps separately if you need JSON string.
fix import json; json_str = json.dumps(obj.serialize())
gotcha Field order in serialized dict may not match class definition order (it follows Python's dict ordering in 3.7+).
fix Use `field.OrderField` or configure Meta ordering if needed.

Define a serializer class with fields, then serialize/deserialize objects.

from yasoo import Serializer, fields

class UserSerializer(Serializer):
    name = fields.String()
    age = fields.Integer()

obj = UserSerializer(name='Alice', age=30)
data = obj.serialize()
print(data)  # {'name': 'Alice', 'age': 30}

# Deserialize
data = {'name': 'Bob', 'age': '25'}
obj = UserSerializer.deserialize(data)
print(obj.name, obj.age)  # Bob 25 (age coerced to int)