Deserialize JSON into existing object (Java)

You can do this using Jackson:

mapper.readerForUpdating(object).readValue(json);

See also Merging Two JSON Documents Using Jackson


If you can use another library instead of Jackson you can try Genson http://owlike.github.io/genson/. In addition of some other nice features (such as deserialize using a non empty constructor without any annotation, deserialize to polymorphic types, etc) it supports deserialization of JavaBean into an existing instance. Here is an example:

BeanDescriptorProvider provider = new Genson().getBeanDescriptorFactory();
BeanDescriptor<MyClass> descriptor = provider.provide(MyClass.class, genson);
ObjectReader reader = new JsonReader(jsonString);
MyClass existingObject = descriptor.deserialize(existingObject, reader, new Context(genson));

If you have any question don't hesitate to use its mailing list http://groups.google.com/group/genson.