-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Code:
@Test
public void testNoReadingFullWriting() {
String json = "{\"a\":100,\"b\":\"bb\",\"x\":-100,\"y\":\"YY\",\"z\":314,\"obj\":{\"id\":100}}";
BigData0 obj = JsonUtils.fromJson(json, BigData0.class);
assertNotNull(obj);
assertNotNull(obj.getTree());
assertEquals(6, obj.getTree().size());
String str = JsonUtils.toJson(obj);
assertEquals(json, str);
assertNotNull(obj.getTree());
}
private static class BigData0 extends JsonContainer {
}
public abstract class JsonContainer {
private ObjectNode tree;
protected ObjectNode getTree() {
return tree;
}
protected void setTree(ObjectNode tree) {
this.tree = tree;
}
}
Then i have a jackson module and method (in JsonUtils) that check when an object is an instance of JsonContainer and when it is, it is supposed to serialize and deserialize in a special (deserialization set the tree attribute, serialization uses the module that extends BeanSerializer and overrides serializeFields...
Problem is that with jackson 2 now, when the class doesn't have any attributes, it just uses the unknown deserializer by default... and skips checking whether a bean serializer might be available...
I understand this is a very brief, possibly incomprehensible explanation... The entire thing solution i had to write in jackson 1 is on stackoverflow though:
http://stackoverflow.com/questions/17967531/jackson-api-partially-update-a-string
In short: the whole problem was to deserialize a huge json blob with only a partial knowledge/class representation of its content but still be able to save the entire thing back.
I wish jackson supports that in the first place.