java - convert json to object using jackson -


i have convert json object using jackson. class like:

class country {       int a;       int b;   }   

and json getting:

{"country":{"a":1,"b":1}} 

but when trying deserialize giving me following error

org.codehaus.jackson.map.jsonmappingexception: unrecognized field "country"     

if remove "country", able object.

is there way can tell jackson ignore "country" json string?

thanks in advance.

this correct behavior of jackson, actual json representation of country object should without top level country. if json absolutely has top level country attribute, cleaner approach use wrapper country class this:

class wrappercountry {      country country; } 

this way json representation should correctly deserialize wrappercountry object , can retrieve country that.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -