Can jackson parser Object from json if I add or delete some field? -


in work, want use jackson in situation:

{   "student": {       "name" : "hello",       "id" : "stu_001"   } } 

then, define class student:

class student {    public string name;    public string id;    //get , set methods } 

but, in case, json be:

{   "student": {       "name" : "hello",       "id" : "stu_001",       "age" : "23"   } } 

or:

{   "student": {       "name" : "hello"   } } 

all in all, want use jackson parser students data, when json add or delete filed, how can solve jackson?

thank you~

oops!

i search google, , find answer!

use following code:

```objectmapper.configure(org.codehaus.jackson.map.deserializationconfig.feature.fail_on_unknown_properties, false);``` 

when add field original don't have, ignore field.when delete field, assign field "null".


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -