[英]W/System.err: org.json.JSONException: Value <!— of type java.lang.String cannot be converted to JSONObject
String url=AppConfig.URL_IP + "?register=reg&first_name="+fname+"&last_name="+lname+"&email="+email+"&address="+address+"&password="+password+"&number="+number+"&city="+city+"&category="+category;
Log.d("urlll",url);
StringRequest request=new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
boolean checkerror = jsonObject.getBoolean("error");
if (checkerror) {
String error_message = jsonObject.getString("error_msg");
Toast.makeText(getApplicationContext(), error_message, Toast.LENGTH_SHORT).show();
} else {
String sucess_message = jsonObject.getString("sucess_msg");
Toast.makeText(getApplicationContext(), sucess_message, Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),error.getMessage()+"aaaa",Toast.LENGTH_SHORT).show();
}
});
AppController.getInstance().addToRequestQueue(request,"registerAPI");
it is giving me this error: 它给了我这个错误:
W/System.err: org.json.JSONException: Value <!-- of type
java.lang.String cannot be converted to JSONObject
if anyone can solve thanks in advance. 如果有人可以提前解决谢谢。
because you are trying to convert invalid JSON String to jsonObject. 因为您正在尝试将无效的JSON字符串转换为jsonObject。 check you json string in any json validator tool online. 在线检查任何json验证程序工具中的json字符串。 json validator JSON验证器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.