无法将java.lang.String转换为JSONObject
我得到的响应为“成功”,但responseJson值为“null” 这就是我得到的:无法将java.lang.String转换为JSONObject,java,android,json,android-json,Java,Android,Json,Android Json,我得到的响应为“成功”,但responseJson值为“null” 这就是我得到的: responseJson = new JSONObject(response); 如果我能得到一个敬礼就好了 提前感谢。请尝试以下代码: Error converting result org.json.JSONException: Value Fail of type java.lang.String cannot be converted to JSONObject 你的回答是什么?您是否尝试输入响应请
responseJson = new JSONObject(response);
如果我能得到一个敬礼就好了
提前感谢。请尝试以下代码:
Error converting result org.json.JSONException: Value Fail of type java.lang.String cannot be converted to JSONObject
你的回答是什么?您是否尝试输入响应请显示来自
httpClient.execute(httpPost,responseHandler)
的响应。我认为您的服务是本地的,因此无法从上面的URL获得broswer的响应。在这里,我也获得了成功的响应。response=httpClient.execute(httpPost,responseHandler);我认为您的响应不是json或无效的json格式。
Error converting result org.json.JSONException: Value Fail of type java.lang.String cannot be converted to JSONObject
Object json = new JSONTokener(response).nextValue();
if (json instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) json;
// your logic
}else if(json instanceof JSONObject){
//your logic
}