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
Post a Comment