Jackson : Updating (not creating new object) JavaObject from Json?

jackson, java

Solution

Ok found the answer, http://jira.codehaus.org/browse/JACKSON-857 http://jira.codehaus.org/browse/JACKSON-824

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

Problem

OK I have a json say ``` userjson = { fname : "ABC", lname : "DEF" } ``` and a User Pojo Object ``` User { String id, String email, String fname, String lname } ``` now using the Jackson, I know how to create User instance from userjson, but how do i update existing User instance from userjson, because my user instance has some properties already set by some other Module. For now what i am doing is converting userjson to userHasMap and then set all the values manually ``` userInstance.setFName(userHasMap.get('fname')) userInstance.setLName(userHasMap.get('lname')) ``` which works fine, but I could have done some thing for converting userInstance to userjson when needed which would have made use of jackson-lib meaningless.

Original source