繁体   English   中英

W / System.err:org.json.JSONException:值

[英]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");

它给了我这个错误:

W/System.err: org.json.JSONException: Value <!-- of type 
java.lang.String cannot be converted to JSONObject

如果有人可以提前解决谢谢。

因为您正在尝试将无效的JSON字符串转换为jsonObject。 在线检查任何json验证程序工具中的json字符串。 JSON验证器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM