Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 嵌套JSONObject_Java_Json_Nested - Fatal编程技术网

Java 嵌套JSONObject

Java 嵌套JSONObject,java,json,nested,Java,Json,Nested,我在JSONObject和JSONArray方面有几个问题。 我想解析这个json文件: [{ "SourceFile": "AndresIniesta.flv", "ExifTool": { "ExifToolVersion": 8.22 }, "System": { "FileName": "AndresIniesta.flv", (...) }, "File": { "FileType": "FLV", "MIMEType":

我在JSONObject和JSONArray方面有几个问题。
我想解析这个json文件:

[{
  "SourceFile": "AndresIniesta.flv",
  "ExifTool": {
    "ExifToolVersion": 8.22
  },
  "System": {
    "FileName": "AndresIniesta.flv",
    (...)
  },
  "File": {
    "FileType": "FLV",
    "MIMEType": "video/x-flv"
  },
  "Flash": {
    "Duration": "04:09",
    "Starttime": 0,
    "Totalduration": 249.36,
    "ImageWidth": 320,
    (...)
  },
  "Composite": {
    "ImageSize": "320x240"
  }
}]
但不是所有的,只是场闪。
整个文件是一个JSONArray,但只有一个元素。我在闪光灯上看到了这段代码:

JsonMappingException,IOException{

字符串a=新字符串();
输入流是= 这是.getClass().getClassLoader().getResourceAsStream( “a.json”);
字符串jsonTxt=IOUtils.toString(is);
JSONArray json=(JSONArray)JSONSerializer.toJSON(jsonTxt);
JSONObject flash=json.getJSONObject(0)

System.out.print(“flash->”+flash.getString(“flash”)

但我不知道如何访问Flash文件、lis持续时间、Starttime…等等

当我这样尝试时:

字符串可浏览时间= flash.getString(“Canseekontime”);
int起始时间= flash.getInt(“Starttime”);
Double duration=flash.getDouble(“duration”)

我得到这个错误:
net.sf.json.JSONException:JSONObject[“Duration”]
未找到

有什么帮助吗

提前谢谢你是说

JSONObject flash = json.getJSONObject(0); 
JSONObject Flash = flash.getJSONObject("Flash"); 
int starttime = Flash.getInt("Starttime");