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

Ok i have json say

userjson = { fname : "ABC", lname : "DEF" }

and a custom Pojo object

User {
 String id, 
 String email,
 String fname,
 String lname
}

Now, using my Jackson, I know how to create a user instance from userjson, but how to upgrade an existing user instance from userjson because my user instance has some properties already set by another module.

Currently what I am doing is converting userjson to userHasMap and then manually setting all the values

userInstance.setFName(userHasMap.get('fname'))
userInstance.setLName(userHasMap.get('lname'))

whoch works fine, but cud did something to convert userInstance to userjson when needed, to use jackson-lib is pointless.

+4
source share
1 answer
+6

Source: https://habr.com/ru/post/1543191/


All Articles