{
"result": 0,
"data": {
"result": {
"mid": 2672,
"mpath": [
"http://v2.mukewang.com/1c1161cb-69e4-4842-be05-f9594594f018/L.mp4?auth_key=1472117576-0-0-5a0602457ff03c532cbe64fc056be9ae",
"http://v2.mukewang.com/1c1161cb-69e4-4842-be05-f9594594f018/M.mp4?auth_key=1472117576-0-0-b0c72281c620105d000b842d7c092082",
"http://v2.mukewang.com/1c1161cb-69e4-4842-be05-f9594594f018/H.mp4?auth_key=1472117576-0-0-34f1262f9d72978092e1773101ad9a7b"
],
"cpid": "736",
"name": "创建ContextMenu菜单",
"time": 0,
"practise": []
}
},
"msg": "成功"
}
上面是一个网址解析的Json代码
通过再一次使用Json解析,才明白对于{}而言,是一个JSONObject,而对于[]而言,是一个JSONArray
JSONArray里面不一定是JSONObject,比如上面的mpath中是字符串,JSONArray获取的时候就应该用getString方法,见下面的代码
//这个Document就是个Json代码
jsonData=jsonDoc.text();
//通过Json字符串创建Json对象
jsonObject=new JSONObject(jsonData);
mpath=jsonObject.getJSONObject("data").getJSONObject("result").getJSONArray("mpath");
String downloadPath=mpath.getString(videoDef).toString().trim();
参见以前写的Json生成与解析:
http://blog.youkuaiyun.com/molu_chase/article/details/52300870
http://blog.youkuaiyun.com/molu_chase/article/details/52300968
。。