org.json.JSONException: 类型 java.lang.String 的值 <div 在调试期间无法转换为 JSONObject
org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject during the debugging
I develope android application ,one of my concept is pass user rating of an android application
all are required paramter to pass ratelogin asynchronus ,
When i run my Android application i got the Exception during the debugging my application ,i gave my exception below,please any one give the solution for this problem..thanks in advance.
**My exception is**
>org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject
我的活动:
//参数传递给 RateLogin 异步任务的地方
new rateLogin().execute(userid, Strbookid,userrating, Deviceid);
//Asychronus task for ratelogin
class rateLogin extends AsyncTask<String, String, String> {
String userid = "";
String Strbookid = "";
String userRating="";
String Deviceid = "";
@Override
protected String doInBackground(String... strings) {
userid = strings[0];
Strbookid = strings[1];
userRating=strings[2];
Deviceid = strings[3];
/*登录率:XMl Http Post
这里登录用户id,图书id,用户给定的应用率,移动设备id
*/
HttpClient httpClient = new DefaultHttpClient();
// 创建 HTTP Post
HttpPost httpPost = null;
List<NameValuePair> nameValuePair = null;
httpPost = new HttpPost(
Rateurl);
// Building post parameters and key and value pair
nameValuePair = new ArrayList<NameValuePair>(4);
nameValuePair.add(new BasicNameValuePair("userid", userid));
nameValuePair.add(new BasicNameValuePair("bookid", Strbookid));
nameValuePair.add(new BasicNameValuePair("userrating", userRating));
nameValuePair.add(new BasicNameValuePair("deviceid", Deviceid));
// Url Encoding the POST parameters and writing error to Log
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
// Making HTTP Request to user rating value
HttpResponse response = httpClient.execute(httpPost);
try
{
//this line only got Exception
String strRet = HttpHelper.request(response);
// writing exception to log of Rate login
}catch(Exception e)
}
Log.d(strRet, "strstrRet");
JSONObject jsonObjRecv=null;
jsonObjRecv = new JSONObject(strRet);
String result = jsonObjRecv.getString("status");
String message = jsonObjRecv.getString("info");
if (result.equals("Success")) {
showalert(message);
}
else {
showalert(message);
}
return null;
}
}
我认为您从服务器收到了错误的响应。如果您调试应用程序,您会发现您的响应是这样的
我遇到了同样的问题。所以它的服务器错误不是android.......
I develope android application ,one of my concept is pass user rating of an android application
all are required paramter to pass ratelogin asynchronus ,
When i run my Android application i got the Exception during the debugging my application ,i gave my exception below,please any one give the solution for this problem..thanks in advance.
**My exception is**
>org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject
我的活动: //参数传递给 RateLogin 异步任务的地方
new rateLogin().execute(userid, Strbookid,userrating, Deviceid);
//Asychronus task for ratelogin
class rateLogin extends AsyncTask<String, String, String> {
String userid = "";
String Strbookid = "";
String userRating="";
String Deviceid = "";
@Override
protected String doInBackground(String... strings) {
userid = strings[0];
Strbookid = strings[1];
userRating=strings[2];
Deviceid = strings[3];
/*登录率:XMl Http Post
这里登录用户id,图书id,用户给定的应用率,移动设备id
*/
HttpClient httpClient = new DefaultHttpClient();
// 创建 HTTP Post
HttpPost httpPost = null;
List<NameValuePair> nameValuePair = null;
httpPost = new HttpPost(
Rateurl);
// Building post parameters and key and value pair
nameValuePair = new ArrayList<NameValuePair>(4);
nameValuePair.add(new BasicNameValuePair("userid", userid));
nameValuePair.add(new BasicNameValuePair("bookid", Strbookid));
nameValuePair.add(new BasicNameValuePair("userrating", userRating));
nameValuePair.add(new BasicNameValuePair("deviceid", Deviceid));
// Url Encoding the POST parameters and writing error to Log
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
// Making HTTP Request to user rating value
HttpResponse response = httpClient.execute(httpPost);
try
{
//this line only got Exception
String strRet = HttpHelper.request(response);
// writing exception to log of Rate login
}catch(Exception e)
}
Log.d(strRet, "strstrRet");
JSONObject jsonObjRecv=null;
jsonObjRecv = new JSONObject(strRet);
String result = jsonObjRecv.getString("status");
String message = jsonObjRecv.getString("info");
if (result.equals("Success")) {
showalert(message);
}
else {
showalert(message);
}
return null;
}
}
我认为您从服务器收到了错误的响应。如果您调试应用程序,您会发现您的响应是这样的
我遇到了同样的问题。所以它的服务器错误不是android.......