Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.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 对象不是';这不是一个有效的JSONArray_Java_Android_Json - Fatal编程技术网

Java 对象不是';这不是一个有效的JSONArray

Java 对象不是';这不是一个有效的JSONArray,java,android,json,Java,Android,Json,我的JsonString: {"Data":{"pics":{"24":{"ID":"24","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/010.jpg"},"23":{"ID":"23","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/009.jpg"},"22":{"ID":"22","LINK":

我的JsonString:

{"Data":{"pics":{"24":{"ID":"24","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/010.jpg"},"23":{"ID":"23","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/009.jpg"},"22":{"ID":"22","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/008.jpg"},"21":{"ID":"21","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/007.jpg"},"20":{"ID":"20","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/006.jpg"},"19":{"ID":"19","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/005.jpg"},"18":{"ID":"18","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/004.jpg"},"17":{"ID":"17","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/003.jpg"},"16":{"ID":"16","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/002.jpg"},"15":{"ID":"15","LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/001.jpg"},"14":{"ID":"14","LINK":"http:\/\/orf.at\/mojo\/1_1\/storyserver\/\/news\/images\/logo.newsorfon.png"}}},"Message":null,"Code":200}
我想解析它,将id和链接放入我的树状图中

我的代码:

JSONObject parse = new JSONObject(msg.obj.toString());
                JSONObject data = parse.getJSONObject("Data");
                JSONArray arr = data.getJSONArray("pics");
                for (int i = 0; i<arr.length(); i++) {
                    JSONObject obj = arr.getJSONObject(i);
                    list.put(Integer.parseInt(obj.getString("ID")), obj.getString("LINK"));
                    Log.e("FunPics",obj.getString("ID")+ " " + obj.getString("LINK"));
                }
JSONObject parse=newjsonobject(msg.obj.toString());
JSONObject data=parse.getJSONObject(“数据”);
JSONArray arr=data.getJSONArray(“pics”);

对于(int i=0;i
不是数组,它是一个对象,数组由
[
]
表示(如指定):


pics
不是数组,它是一个对象,数组通过位于
[
]
中表示(如指定):


“pics”是一个jsonObject而不是jsonArray,所以写
数据。getJSONObject(“pics”)
代替
数据。getJSONArray(“pics”);

“pics”是一个jsonObject而不是jsonArray,所以写
数据。getJSONObject(“pics”)
代替
数据。getJSONArray(“pics”);
pics键将jsonObject作为值而不是jsonArray

JSONObject picsJson=data.getJSONObject(“pics”);

你必须遍历所有的键并获得图片的每个信息。使用键迭代器,检查下面的链接


pics键将jsonObject作为值,而不是jsonArray

JSONObject picsJson=data.getJSONObject(“pics”);

你必须遍历所有的键并获得图片的每个信息。使用键迭代器,检查下面的链接


将json字符串放入json数组我的意思是将“msg.obj.toString()”放入getJSONArray()而不是“pics”,然后使用for循环get“pics”作为jsonobject…!!还有一个“更多”的问题是来自webservice的JSONString是错误的,它必须采用[{数据:…}]格式将json字符串放入json数组我的意思是放入“msg.obj.toString()”进入getJSONArray()而不是“pics”,然后使用for循环get“pics”作为jsonobject…!!还有一个“更多”问题是来自webservice的JSONString是错误的,它必须采用[{Data:…}]格式
{
"Data":{
    "pics":{
        "24":{
            "ID":"24",
            "LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/010.jpg"
        },
        "23":{
            "ID":"23",
            "LINK":"http:\/\/www.orschlurch.net\/wp-content\/gallery\/pixxdump-144\/009.jpg"
        },
    }
},
....
"Message":null,
"Code":200
}
Iterator keys = picsJson.keys();
while(keys.hasNext()) {