i have following class:
@jsonrootname(value = "customer") @jsonignoreproperties(ignoreunknown = true) public class data{ @jsonproperty("salutation") public string salutation; @jsonproperty("firstname") public string firstname; @jsonproperty("lastname") public string lastname; @jsonproperty("birthdate") public string birthdate; }
i want transform incoming json pojo. json this:
{ "customer": { "lastname": "test lastname", "firstname": "test firstname", "salutation": "test salutation", "birthdate": "test date", "addresses": { "city": "test city", "postalcode": "test postal code", "country": "test country", "streetnumber": "test number", "street": "test street" } } }
problem: actual data not in root tag, nested in "customer"
. why used @jsonrootname
. there data city, postalcode, in addresses, not need object instance. why added jsonignoreproperties(ignoreunknown = true)
.
when use:
return mapper.readvalue(getresource("/test.json"), data.class);
it returns me instance of data, null on every attribute of it. how can fix , why doesn't work? first time using jackson mapper here.. thanks!
Comments
Post a Comment