我有以下 JSON 数据:
{
"customer": [
{
"cus_name": "ravi sharma",
"cus_email": "sk@yahoo.com",
"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"
}
]
}
当我尝试cus_pass_reset_ques
从 JSON 获取关键数据时,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