0

when deserializing below JSON, it fails with above exception message when trying to parse the server attribute which has its type 'string' nested within it, how to parse a JSON which is having the attribute types nested within each attribute like below?

{
  "header": {
    "time": 1492178674232,
    "threadId": null,
    "requestMarker": null,
    "env": null,
    **"server": {
      "string": "astapp078"
    }**,
    "service": {
      "string": "ApiCalendarsEntityStreamPublisher"
    }
  }
}
4

1 回答 1

0

您可以使用@JsonProperty注释为 JSON 字段指定与 POJO 字段不同的名称。server并将andservice字段包装在类中。例如

class POJO {
    Server server;
    Service service;
}

class Server {
    @JsonProperty("string") String name;
}

class Service {
    @JsonProperty("string") String name;
}

nameserver是_"astapp078"

于 2017-04-26T09:29:29.597 回答