0

Below is the Json I am converting to a POJO using jackson:

[
    [
        {
             "title"  : "Professional JavaScript",
             "author" : "Nicholas C. Zakas"
        },
        {
            "title" : "JavaScript: The Definitive Guide",
            "author" : "David Flanagan
        },
    ],
    [
        {
            "title" : "High Performance JavaScript",
            "author" : "Nicholas C. Zakas"
        },
        {
            "title"  : "Professional JavaScript",
            "author" : "Nicholas C. Zakas"
        },
        {
           "title" : "JavaScript: The Definitive Guide",
            "author" : "Nicholas C. Zakas"
        }
    ]
]

I am getting the following error

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.test.sample.jsonsample out of START_ARRAY token

below is my class

public class jsonsample
{
   @JsonProperty("title")
   public String title;
   @JsonProperty("author")
   public String author;
  //getters and setters
}

public class mainclass
{
  public List<jsonsample> sjson;
}

ObjectMapper mapper = new ObjectMapper();
List<mainclass> accs = mapper.readValue(rspString,mapper.getTypeFactory().constructCollectionType(List.class, mainclass.class));

How can I get data from the nested structure, and also with unnamed arrays?

nbrooks
  • 18,126
  • 5
  • 54
  • 66
Anji R
  • 843
  • 3
  • 16
  • 23

0 Answers0