Skip to content

resource_attribute_index_serializer.py

ofrak.service.serialization.serializers.resource_attribute_index_serializer

ResourceAttributeIndexSerializer (SerializerInterface)

Serialize and deserialize ResourceAttributeIndex[T] into PJSONType.

The default serializer works for ResourceAttributeIndex, we just need to handle ResourceAttributeIndex[T]. This is done by ignoring the type argument and using ResourceAttributeIndex as type hint instead.

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/resource_attribute_index_serializer.py
def obj_to_pjson(self, obj: ResourceAttributeIndex, type_hint: Any) -> PJSONType:
    return self._service.to_pjson(obj, ResourceAttributeIndex)

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/resource_attribute_index_serializer.py
def pjson_to_obj(self, pjson_obj: PJSONType, type_hint: Any) -> ResourceAttributeIndex:
    return self._service.from_pjson(pjson_obj, ResourceAttributeIndex)