GitHub user pjfanning edited a discussion: Adding custom 
serialization/deserialization for certain classes

I'm experimenting writing a serialization module that can be used with Apache 
Pekko. Pekko's main serialization module is Jackson based. That Jackson based 
implementation has a few custom serializers/deserializers for some important 
classes.
I need to be able to serialize/deserialize a class that looks like
`class Command(T payload, ActorRef ref)`

The existing ActorRef serializer/deserializer serializes an address value as a 
String instead trying to serialize all the state of the ActorRef.

Would it be possible to consider Fory support for registering custom 
serializer/deserializer combos for some classes and that these classes can be 
embedded in classes? In the Command class above, I would want to get Fory to 
serialize the full Command but when it gets to handling the ActorRef field that 
it uses the custom serializer that I have registered with Fory for the ActorRef 
class.

One idea would be on ForyBuilder to support
`registerCustomSerialization<T, S>(Class<T> clazz, Function<T, S> serializeFn, 
Function<S, T> deserializeFn, boolean supportSubclasses)`

So when we run into an object instance in structured data that has a Class that 
matches T then we use the serializeFn to convert to class S, and on 
deserialization, we use the equivalent deserializeFn that converts from type T 
to type S.
If `supportSubclasses` is set to true, S and any subclass of S is supported. 
Otherwise, the S check is an exact match.


GitHub link: https://github.com/apache/fory/discussions/2393

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to