通过检索json数据按类型过滤数据

时间:2019-09-12 06:08:26

标签: mysql json android-studio filter

我已经正确地从json检索了数据,该数据显示了url中的所有数据。我在那里有不同类型的数据,所以我想按主题类型过滤主题,只显示那些数据,而不是全部。

我试图获取密钥,但是对我来说不起作用。

JsonObjectRequest Request = new JsonObjectRequest(Request.Method.GET, baseUrl, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    JSONArray jsonArray = response.getJSONArray("Product");

                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject product = jsonArray.getJSONObject(i);

                        if (product.has("Type")){
                        String name =product.getString("name");
                        }

                        List.add(new User(name));
                    }

//adapter
//recyclerview

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        });

        mQueue.add(Request);

我想显示相同类型的数据,但它显示列表中的所有数据

0 个答案:

没有答案