java - Data of type org.json.JSONObject cannot be converted to JSONArray -
i can't understand, why have error:
04-24 22:11:51.263: w/system.err(27504): org.json.jsonexception: value
<!--here json value-->@ data of type org.json.jsonobject cannot converted jsonarray
this code:
jsonobject getprogile = null; try { //get json getprogile = new jsonobject(customhttpclient.executehttpget(profilegeturl).tostring()); //convert array jsonarray array = getprogile.getjsonarray("data"); (int = 0; < array.length(); i++) { jsonobject c = array.getjsonobject(i); //get tag_customer jsonobject customer = c.getjsonobject("customer"); pname = customer.getstring("name"); plname = customer.getstring("name"); } upd: json
{ "status": "success", "data": { "customer": { "id": "33", "company_id": "1", "name": "sdfsdf", "birthdate": "14.02.1989", "email": "dsfsdf@sf.ff", "photo": "/files/clients_photos/33/(null)", "bonuses": "50", "created": "2015-02-14 12:22:46", "modified": "2015-02-14 12:22:46", "ref_id": null, "ref_code": "6363696029", "banned": null, "ban_reason": null, "ban_ending": null }, "customervisit": [], "customerbonus": [ { "id": "29", "customer_id": "33", "user_id": "4", "product_id": null, "operation": "plus", "amount": "50", "subject": "Загрузка фото при регистрации.", "remain": null, "modified": "2015-02-14 12:22:46", "date": "14.02.2015", "created": "14.02.2015 12:22" } ], "customercar": [ { "id": "41", "customer_id": "33", "car_brand_id": "9", "car_model_id": "11530", "year": "2020", "vin": "sdfsdfsdf", "photo": "", "number": "dsfsdf", "created": "2015-02-14 12:22:46", "modified": "2015-02-14 12:22:46", "car_brand_name": "bmw", "car_model_name": "323" } ], "customerphone": [ { "id": "41", "customer_id": "33", "phone": "+380990010222", "created": "2015-02-14 12:22:46", "modified": "2015-02-14 12:22:46" } ], "insurance": [], "event": [], "review": [], "reservation": [] } }
json shows data jsonobject rather jsonarray, call getprofile.getjsonobject ("data")
Comments
Post a Comment