1
我有以下JSON數據:JSON getString()從字符串中刪除空格嗎?
{
"customer": [
{
"cus_name": "ravi sharma",
"cus_email": "[email protected]",
"cus_pass": "pass",
"cus_mob": "91111111",
"cus_add": "new delhi India",
"cus_pass_reset_ques": "What is your lucky no.?",
"cus_pass_reset_ans": "987"
}
]
}
當我試圖從JSON cus_pass_reset_ques
關鍵數據,getString()
刪除空格的字符串。
try {
JSONArray earthquakes = json.getJSONArray("customer");
for (int i = 0; i < earthquakes.length(); i++) {
JSONObject e = earthquakes.getJSONObject(i);
String a = e.getString("cus_name");
String b = e.getString("cus_email");
String c = e.getString("cus_pass");
String d = e.getString("cus_mob");
String h = e.getString("cus_add");
String f = e.getString("cus_pass_reset_ques");
String g = e.getString("cus_pass_reset_ans");
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
那麼我怎麼才能得到上面的JSON的實際數據。
這個問題已經解決了,感謝 - http://www.androidaspect.com/2013/05/android-json-parsing-tutorial.html
你使用的是什麼JSON框架?它沒有意義,它刪除了空間。 – Darwind 2013-05-07 12:20:48
爲什麼不發佈一些更多的代碼 - 它可以更容易地診斷問題。 – Nick 2013-05-07 12:21:36
你是怎麼做到的? – waqaslam 2013-05-07 12:21:41