Query a JSONObject in java

后端 未结 6 1712
鱼传尺愫
鱼传尺愫 2020-11-27 06:12

I was wondering if somewhere out there exists a java library able to query a JSONObject. In more depth I\'m looking for something like:



        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 07:17

    I've just unexpectedly found very interesting project: JSON Path

    JsonPath is to JSON what XPATH is to XML, a simple way to extract parts of a given document.

    With this library you can do what you are requesting even easier, then my previous suggestion:

    String hello = JsonPath.read(json, "$.data.data2.value");
    
    System.out.println(hello); //prints hello
    

    Hope this might be helpful either.

提交回复
热议问题