"papers": [
{
"files": [
{
"url": "http://farnsworth.papro.org.uk/file/977",
"type": "Initial XML version of the paper",
"name": "c6938201-dac0-4ef9-91cd-ca6e8c30f4b8.xml"
},
{
"url": "http://farnsworth.papro.org.uk/file/978",
"type": "Final annotated XML file",
"name": "c6938201-dac0-4ef9-91cd-ca6e8c30f4b8_final.xml"
}
]
如何在此json文件中获取第一个url
?到目前为止我所拥有的是:
JSONObject file = (JSONObject) files.get(j);
String url = (String) file.get("url");
System.out.println(url);
答案 0 :(得分:1)
这样的事情应该有效:
JSONArray results = d.getJSONArray("files");
JSONObject p = (JSONObject)results.get(0);
url = p.getString("url");