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
非常感謝你!我有這個想法:) –