ObjectMapper with nested object

June 06, 2021, at 10:00 AM

I have JSON response with an array but is not mapping and throwing error, how I can handle JSON like this

"Content":{"Headers":{"Content-Type":["multipart/mixed; \tboundary=\"----=_Part_27_47303298.1622881481751\""],
"Date":["Sat, 5 Jun 2021 11:24:42 +0300 (EEST)"],

I tried to map like this

 public static class ResponseDto{
        Integer total;
        Integer count;
        Integer start;
        List<ItemDto> items;

public static class ItemDto{
        String id;

and I get an error:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ID" (class package.api.utils.ApiMailHogUtil$ItemDto), not marked as ignorable (one known property: "id"])
 at [Source: (StringReader); line: 1, column: 50] (through reference chain: package.api.utils.ApiMailHogUtil$ResponseDto["items"]->java.util.ArrayList[0]->package.api

What I am doing wrong?

Answer 1

As commented, Jackson doesn't find "ID" field so it throws an exception. You can add @JsonProperty("ID") on top of id field in ItemDto:

public static class ItemDto{
        String id;
        // other fields
this.app.service(&hellip;).create(&hellip;) is not a function

this.app.service(…).create(…) is not a function

I tried to make api request twice and the first one work, but the second fails with below error

mglearn.plots.plot_2d_separator (eps=0.5) , what is that,&ldquo;eps&rdquo;?

mglearn.plots.plot_2d_separator (eps=0.5) , what is that,“eps”?

Im' learning Python from the book,"introduction to Machine learning with Python"

ASP.NET JavaScript onClick function

ASP.NET JavaScript onClick function

I have an indexcshtml page, in it there is a button:

Laravel whereNotIn not working as subquery

Laravel whereNotIn not working as subquery

Hello wonderful people of SO!