首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >java json github-api git github pull-request循环获取jsonpath解析resttemplate spring spring-boot

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

Stack Overflow用户
提问于 2017-12-22 17:43:58
回答 1查看 132关注 0票数 0

我从github api (/repos/:owner/:repo/pulls).的请求中获得了一个json字符串,然后使用JsonPath.parse(json).将其parsedDocumentContext

现在我想使用read(path)函数遍历我的DocumentContext,但是github api没有大小/长度或拉取请求的数量。

代码语言:javascript
复制
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

(附言:请温文点,我是新手。)

EN

回答 1

Stack Overflow用户

发布于 2017-12-22 18:27:26

代码语言:javascript
复制
String json = "...";
DocumentContext dc = JsonPath.parse(json);
List<String> listOfValues = dc.read("$.[?].key");

然后,您可以遍历listOfValues

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47939228

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档