GitHub user chaokunyang added a comment to the discussion: Adding custom 
serialization/deserialization for certain classes

Fory do have custimized serializer support, you can refer to 
https://fory.apache.org/docs/docs/guide/java_object_graph_guide#register-custom-serializers

```java
class Foo {
  public long f1;

  private void writeObject(ObjectOutputStream s) throws IOException {
    System.out.println(f1);
    s.defaultWriteObject();
  }
}

class FooSerializer extends Serializer<Foo> {
  public FooSerializer(Fory fory) {
    super(fory, Foo.class);
  }

  @Override
  public void write(MemoryBuffer buffer, Foo value) {
    buffer.writeInt64(value.f1);
  }

  @Override
  public Foo read(MemoryBuffer buffer) {
    Foo foo = new Foo();
    foo.f1 = buffer.readInt64();
    return foo;
  }
}

Fory fory = getFory();
fory.registerSerializer(Foo.class, new FooSerializer(fory));
```

GitHub link: 
https://github.com/apache/fory/discussions/2393#discussioncomment-13678614

----
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