我试图执行该代码为我的应用程序:值0类型为java.lang.Integer不能转换为JSONObject的
JSONObject json = jsonParser.makeHttpRequest(url_kickit_connect,
"POST", params);
// check log cat for response
Log.d("Create Response", json.toString());
try {
int response = json.getInt(TAG_RESPONSE);
if (response == 0){
Toast.makeText(getApplicationContext(), "email " +mail , Toast.LENGTH_SHORT).show();
}
}
catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
虽然得到一个0的返回值,0应该被解析为这段代码中的JSONObject(以上我做标准Httppost和StringBuilder的):
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
的JSON值,我从我的MySQL侧得到(.PHP):
else
{
$response = 0;
echo json_encode($response);
}
但我得到这个错误的logcat:
02-26 09:24:14.920: E/JSON Parser(619): Error parsing data org.json.JSONException: Value 0 of type java.lang.Integer cannot be converted to JSONObject
如果我试图改变的值,或字符串数据类型等错误信息只是改变到告知值或数据类型。 我该如何解决这个问题?
你能张贴JSON价值呢? – 2013-02-26 09:43:17
看到这个http://stackoverflow.com/questions/11991971/what-should-i-do-to-solve-this-error – TheWhiteRabbit 2013-02-26 09:45:55