Default POJO deserialization, containing another POJO with custom deserialization.

9 views
Skip to first unread message

Oleksandr Khamylov

unread,
Aug 16, 2014, 10:20:22 AM8/16/14
to jackso...@googlegroups.com
Hi there. 
Trying to find out how to handle the next situation.
F.x.

public class ClassA {
    String b;
    boolean c;
    Pair p; 
// constructors, getters, setters
}
 
public class Pair {
      String x;
      String y;
// constructors, getters, setters
}


In JSON I want this stuff to look smth. like this:
     "b" : "value b",
     "c" : true,
     "pair" : "x=>y"
}

Can't get it working just specifying a custom JsonDeserializer for Pair class.

Why haven't I written simply JsonDeserializer for ClassA is because I have similar classes (ClassB, ClassC) that contain Pair object as well.
I this case I need to write JsonDeserializer for each class containing Pair object.

Does anyone have an idea about solution?
Reply all
Reply to author
Forward
0 new messages