com.fasterxml.jackson.databind.exc.MismatchedInputException:无法从START_OBJECT令牌中反序列化java.util.ArrayList的实例

时间:2019-10-24 10:45:35

标签: java json jackson deserialization objectmapper

如何使用JSON JacksonObjectMapper下面阅读?我已经开发了代码,但是遇到了错误。

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token
 at [Source: (File); line: 7, column: 19] (through reference chain: com.example.demo.resources.Orgnization["secondaryIds"])

JSON

{
  "id": "100000",
  "name": "ABC",
  "keyAccount": false,
  "phone": "1111111",
  "phoneExtn": "11",
  "secondaryIds": {
    "ROP": [
      "700010015",
      "454546767",
      "747485968",
      "343434343"
    ],
    "AHID": [
      "01122006",
      "03112001"
    ]
  }
}

1 个答案:

答案 0 :(得分:1)

您需要启用ACCEPT_SINGLE_VALUE_AS_ARRAY功能。可能在{{ tag }}中有一个<div> <span *ngFor="let tag of saved.tags" class="badge badge-pill badge-primary"> {{tag}} </span> </div> ,但是当*ngFor POJO有效载荷中只有一个元素时,将不使用数组括号。

List