我从github api (/repos/:owner/:repo/pulls).的请求中获得了一个json字符串,然后使用JsonPath.parse(json).将其parsed到DocumentContext中
现在我想使用read(path)函数遍历我的DocumentContext,但是github api没有大小/长度或拉取请求的数量。
String json = https://api.github.com/repos/:owner/:repo/pulls
DocumentContext dc = JsonPath.parse(json)
for (int i = 0; i < dc.read($.somethingLikeSize); i++){
//get the objects
private int id = dc.read($.[i]...);
//...
}正如我猜测的那样,open_issues_count或open_issues可以是拉请求,但它们不是必须的。
我如何迭代我的documentContext.read($.[i]...) without getting a PathNotFoundException?
(附言:请温文点,我是新手。)
发布于 2017-12-22 18:27:26
String json = "...";
DocumentContext dc = JsonPath.parse(json);
List<String> listOfValues = dc.read("$.[?].key");然后,您可以遍历listOfValues
https://stackoverflow.com/questions/47939228
复制相似问题