Parsing a subset of JSON in Java using Jackson

前端 未结 4 2336
花落未央
花落未央 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:36

    Yes, it is possible the way you have mentioned in the Pseudo code. "phoneNumbers" is a key and value returned can be passed on to Jackson deserialiying.

    If the response is an array of maps then you can iterate through each one of them and use the yourResponseAsJSONObject.get('phoneNumbers') method to get the value and pass it on to Jackson

    or use JsonPath as mentioned by @dimas

提交回复
热议问题