0
。当我运行我的代码正在接收JSON异常,其中说“类型不匹配”在从json对象获取json数组的点上。 这里是我的代码解析json字符串时,json在android中解析类型不匹配
String dataFromLogin="{"catego":{"id":"2","fname":"Tashen Jazbi","uname":"tashen",
"password":"123","pic_url":"","lati":"33.7167","longi":"73.0667","city":"Islamabad",
"country":"Pakistan","mobid":"000000000000000","street":"xyz",
"dateandtime":"2013-12-29 18:07:52"}}";
try {
JSONObject jsonObj = new JSONObject(dataFromLogin);
//JSONObject response = jsonObj.getJSONObject("catego");
JSONArray contacts = jsonObj.getJSONArray("catego");
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
fullname = c.getString("fname");
uname = c.getString("uname");
pic_url = c.getString("pic_url");
lat = c.getString("lati");
lng = c.getString("longi");
city = c.getString("city");
country = c.getString("country");
street= c.getString("street");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我没发现哪里做错了。如果任何人都可以帮助,那么将非常感激。
谢谢:)
您已经给出答案,我为此投票。 –
@SatyakiMukherjee谢谢。 – Raghunandan
非常感谢你!我有这个想法:) –