Is there something like an OpenRewrite recipe for converting from Jackson to Fury for POJO (struct) mapping? #1973
Answered
by
chaokunyang
crankydillo
asked this question in
Q&A
-
The OpenRewrite community said no. Internet searches suggest there isn't. Doesn't have to be OpenRewrite based. Curious if any converter exists. I understand that serialization/deserialization is typically kept at application boundaries, so less of a need for things like this. Curious nonetheless! |
Beta Was this translation helpful? Give feedback.
Answered by
chaokunyang
Dec 10, 2024
Replies: 1 comment 3 replies
-
Hi @crankydillo , you can take following code as an example: 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);
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We don't have plans to provide such tool. Change the usage from json to fury is not complex. The serialization is encapsulated into an util class. You just need to change that class from using json to fury,which would be pretty straight forward