【发布时间】:2021-10-01 18:42:51
【问题描述】:
我正在尝试通过 reddit 的 json 文件获取作者或其他内容,例如缩略图 url。但如果我运行它,它只会响应错误:com.jayway.jsonpath.PathNotFoundException
我正在使用 Java 和 jsonpath api 来获取路径。
代码:
String url = "https://www.reddit.com/r/gaming/new.json?sort=new";
...
System.out.println("result after Reading JSON Response");
String json = response.toString();
Object document = Configuration.defaultConfiguration().jsonProvider().parse(json);
String author0 = JsonPath.read(document, "$.data[0].children[0].data.author");
System.out.println(author0);
一切正常,除了我无法获得 author0 的值
编辑:我想知道作者,但我不工作。 Response String 和 JSON String 是对的 (https://www.reddit.com/r/gaming/new.json?sort=new)
【问题讨论】:
-
您对此错误有何疑问?
-
我用有用的信息更新了文本