我可以从 php 的 json_encode 获得 json 响应,并且能够在 eclipse 的 logcat 中显示响应是什么:
[{"idusers":"1","full_name":"Test Subject","get_email":"test_subject@gmail.com"},
{"idusers":"2","full_name":"Test Subject_2","get_email":"test_subject_2@gmail.com"}]
现在,我正在尝试
//parse json data
try {
JSONArray jArray = new JSONArray(result);
for(int i =0; i<jArray.length(); i++){
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag","id: "+json_data.getInt("idusers")+
", Full Name: "+json_data.getString("full_name")+
", Email: "+json_data.getString("get_email")
);
}
}catch(JSONException e){
Log.e("log_tag","Error parsin data "+e.toString());
}
但是,我收到一条错误消息
Error parsin data org.json.JSONException: Value testing of type java.lang.String cannot be converted to JSONArray
有没有办法解决 JSONArray 问题?
提前致谢!