0
"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"
    }
  ]

我怎样才能得到url这个 json 文件中的第一个?到目前为止,我所拥有的是:

                JSONObject file = (JSONObject) files.get(j);

                String url = (String) file.get("url");
                System.out.println(url);
4

1 回答 1

1

像这样的东西应该可以工作:

JSONArray results = d.getJSONArray("files");
JSONObject p = (JSONObject)results.get(0);
url = p.getString("url");
于 2013-06-16T00:15:45.590 回答