SerializationΒΆ

Jivago provides an ObjectMapper object which can be used to serialize and deserialize complex objects. Mapped classes do not need to be annotated with the @Serializable annotation.

object_mapper.py

from jivago.serialization.object_mapper import ObjectMapper


class Dto(object):
    name: str


object_mapper = ObjectMapper()

dto: Dto = object_mapper.deserialize('{"name": "paul" }', Dto)

json_str = object_mapper.serialize(dto)

If a constructor (__init__) function is declared on the mapped class, parameters are injected, otherwise parameters are set using the __setattr__ method.