Supposed i have a POJO like this:
class POJO1 {
TypeA getFirst();
TypeA getSecond();
TypeB getThird();
String getName();
}
I'm looking to create a custom serializer that would output this:
{ "A" : [ serializationOf(first), serializationOf(second) ], "B" : serializationOf(second), "name" : valueOfName() }
But here's the catch, it's not specific to POJO1. Meaning the same serialization takes place for this other POJO:
class POJO2 {
TypeA getFirst();
TypeA getSecond();
TypeB getThird();
String getName();
}
Or any class that has TypeA or TypeB properties, meaning the methods can change. I prefer not to target a base class or interface as my serializer is to be used by people developing other classes that i've never even imagined. I've been looking at registering TypeA and TypeB serializers, but they don't seem to allow me to change the key of the json object, nor group similar types in any way.