Android解析json对象之间的json数组
我试图解析这个json数组和json对象,但是给了我一个错误,没有收到任何数据,你能帮我解析这个吗 这里是我的json链接: 这是我的代码:Android解析json对象之间的json数组,android,json,Android,Json,我试图解析这个json数组和json对象,但是给了我一个错误,没有收到任何数据,你能帮我解析这个吗 这里是我的json链接: 这是我的代码: JSONArray jsonarray = new JSONArray(jsStr); for (int i = 0; i <jsonarray.length(); i++) { HashMap<String, String> map = new HashMap&
JSONArray jsonarray = new JSONArray(jsStr);
for (int i = 0; i <jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject jso = jsonarray.getJSONObject(i);
map.put("id_product", jso.getString("id"));
map.put("name", jso.getString("title"));
map.put("model","");
map.put("price", "14000");
map.put("oldprice", "14000");
map.put("logo", jso.getString("thumb"));
arraylist.add(map);
}
JSONArray-JSONArray=新的JSONArray(jsStr);
对于(int i=0;i按如下方式解析此json:
try {
JSONObject jsonObject = new JSONObject(jsonString);
JSONArray array = jsonObject.getJSONArray("items");
for(int i=0;i<array.length();i++){
JSONObject obj = (JSONObject) array.get(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
试试看{
JSONObject JSONObject=新的JSONObject(jsonString);
JSONArray数组=jsonObject.getJSONArray(“项”);
对于(inti=0;i一些类似的
try {
JSONObject data = new JSONObject(jsonString);
JSONArray itemsArray = data.getJSONArray("items");
for (int i = 0; i <itemsArray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject jso = itemsArray .getJSONObject(i);
map.put("id_product", jso.getString("id"));
map.put("name", jso.getString("title"));
map.put("model","");
map.put("price", "14000");
map.put("oldprice", "14000");
map.put("logo", jso.getString("thumb"));
arraylist.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
试试看{
JSONObject数据=新的JSONObject(jsonString);
JSONArray itemsArray=data.getJSONArray(“items”);
对于(inti=0;i我认为问题来自解析。
请使用org.JSON.simple.-111.jar。请通过编辑您的帖子来粘贴错误消息。没有收到数据,错误是我的自定义错误这是完全有效的JSON。您得到了什么错误?可能是操作问题我更新了我的问题请重新阅读您的jsonarray是否得到了所有响应?因为您必须获得第一个完整的对象之后呢