Parsing a subset of JSON in Java using Jackson

前端 未结 4 2317
花落未央
花落未央 2021-02-14 21:51

Given a Json, is it possible to use Jackson to only parse out a section of the message? Say that the data I\'m interested in is buried in a deep hierarchy of fields and I simply

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 22:40

    You can use JsonPath library. With this library you can map your JsonPath output directly into POJO's.

    Pseudo:

    List phoneNrs = JsonPath.parse(json).read("$.my.deep.structure.persons.phoneNumbers", List.class);
    

提交回复
热议问题