GitHub user chaokunyang added a comment to the discussion: Is there something 
like an OpenRewrite recipe for converting from Jackson to Fury for POJO 
(struct) mapping?

Hi @crankydillo , you can take following code as an example:
```java
public class StructMappingExample {
  static class Struct1 {
    int f1;
    String f2;

    public Struct1(int f1, String f2) {
      this.f1 = f1;
      this.f2 = f2;
    }
  }

  static class Struct2 {
    int f1;
    String f2;
    double f3;
  }

  static ThreadSafeFury fury1 = Fury.builder()
    .withCompatibleMode(CompatibleMode.COMPATIBLE).buildThreadSafeFury();
  static ThreadSafeFury fury2 = Fury.builder()
    .withCompatibleMode(CompatibleMode.COMPATIBLE).buildThreadSafeFury();

  static {
    fury1.register(Struct1.class);
    fury2.register(Struct2.class);
  }

  public static void main(String[] args) {
    Struct1 struct1 = new Struct1(10, "abc");
    Struct2 struct2 = (Struct2) fury2.deserialize(fury1.serialize(struct1));
    Assert.assertEquals(struct2.f1, struct1.f1);
    Assert.assertEquals(struct2.f2, struct1.f2);
    struct1 = (Struct1) fury1.deserialize(fury2.serialize(struct2));
    Assert.assertEquals(struct1.f1, struct2.f1);
    Assert.assertEquals(struct1.f2, struct2.f2);
  }
}
```

GitHub link: 
https://github.com/apache/fury/discussions/1973#discussioncomment-11510512

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