Skip to content

basic_type_serializer.py

ofrak.service.serialization.serializers.basic_type_serializer

BasicTypeSerializer (SerializerInterface)

Serialize and deserialize basic types (which don't need any change) into PJSONType.

obj_to_pjson(self, obj, _type_hint)

Serialize the object to PJSON. Note that the generic self._service.to_pjson can be used here.

Source code in ofrak/service/serialization/serializers/basic_type_serializer.py
def obj_to_pjson(self, obj: BasicType, _type_hint: Any) -> BasicType:
    return obj

pjson_to_obj(self, pjson_obj, _type_hint)

Deserialize PJSON into the object. Note that the generic self._service.from_pjson can be used here.

Source code in ofrak/service/serialization/serializers/basic_type_serializer.py
def pjson_to_obj(self, pjson_obj: BasicType, _type_hint: Any) -> BasicType:
    return pjson_obj