【问题标题】:com.android.volley.ParseError: org.json.JSONException error in androidcom.android.volley.ParseError:android 中的 org.json.JSONException 错误
【发布时间】:2022-12-02 18:37:29
【问题描述】:

I\'m trying out a simple coding to build an app with api using volley but get the error jsonexception of type org.json.JSONObject cannot be converted to JSONArray.

                RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
                String url = \"http://ws2.samdel.net/mongodb_api.php\";

                JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, url, null,
                        new Response.Listener<JSONArray>() {
                            @Override
                            public void onResponse(JSONArray response) {

                                Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();

                            }
                        }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_LONG).show();
                        Log.d(\"Error.Response\", error.toString());
                    }
                });

                queue.add(request);

`

I got this error

com.android.volley.ParseError: org.json.JSONException: Value {\"files\":{\"data\":[{\"_id\":{\"$oid\":\"637d0799f79eb6bab4957150\"},\"files_name\":\"G4_Proposal\",\"files_category\":\"proposal\",\"files_keyword\":\"workshop, proposal, student, project\"},{\"_id\":{\"$oid\":\"637d0868f79eb6bab4957151\"},\"files_name\":\"CV_Intern_Adella\",\"files_category\":\"intern student\",\"files_keyword\":\"cv, intern, job, experience, name, matric, university\"}],\"status\":\"OK\"}} of type org.json.JSONObject cannot be converted to JSONArray

Does anyone know what seems to be the problem and how can i fix it? thank you in advance.

    标签: android android-volley


    【解决方案1】:
    猜你喜欢
    • 2016-12-26
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多