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.
Ok found the answer, http://jira.codehaus.org/browse/JACKSON-857 http://jira.codehaus.org/browse/JACKSON-824
mapper.readerForUpdating(object).readValue(json);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With