java json github-api git github pull-request循环获取jsonpath解析resttemplate spring spring-boot

问题描述 投票:0回答:1

我从json的要求得到了一个github api (/repos/:owner/:repo/pulls).字符串然后我parsed使用DocumentContext成为JsonPath.parse(json).

现在我想使用DocumentContext函数迭代我的read(path),但是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可以是pull-requests,但它们不必。

我如何迭代我的documentContext.read($.[i]...) without getting a PathNotFoundException

(PS:请温柔,我是新手。)

java json github-api pull-request jsonpath
1个回答
0
投票
String json = "...";
DocumentContext dc = JsonPath.parse(json);
List<String> listOfValues = dc.read("$.[?].key");

然后你可以迭代listOfValues

© www.soinside.com 2019 - 2024. All rights reserved.