5

I have a JSON like below.

{
  "id": 123,
  "screenId": "abc456",
  "name": "Screen1",
  "description": "screen description",
  "format": [
    {
      "sectionName": "fontType",
      "font": {
        "family": {
          "id": "TIMESNEWROMAN",
          "description": "TIMESNEWROMAN"
        }
      }
    },
    {
      "sectionName": "backgroundColorPanel",
      "color": "#000000"
    },
    {
      "sectionName": "buttonBorderShape",
      "shape": {
        "color": "#000000",
        "type": {
          "id": "SOLID",
          "description": "Solid"
        },
        "size": "12"
      }
    }
  ]
}

I tried the following code to convert it into List<Object[]> but I am getting the exception

code:

JsonNode node =  mapper.readTree(jsonString);
TypeReference<List<Object[]>> typeRef = new TypeReference<List<Object[]>>(){};
List<Object> list = mapper.readValue(node.traverse(), typeRef);

exception:

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

I also tried the following

mapper.readValue(mapper.treeAsTokens(jsonString), TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, Object[].class))

But I am getting the same exception. Can someone help me?

Tiny
  • 27,221
  • 105
  • 339
  • 599
raajaag
  • 175
  • 4
  • 18

0 Answers0