【问题标题】:How can I make Http get request using Volley on this JSON format如何在这种 JSON 格式上使用 Volley 发出 Http 获取请求
【发布时间】:2015-11-02 02:31:29
【问题描述】:

重要提示:所有 id 和键都将被忽略。它们是自动生成的。对于每一行,只有 value 属性与 你。

{"total_rows":3,"offset":0,"rows":[
{"id":"0342fde43316bffdea32d0ec990dba4e","key":"0342fde43316bffdea32d0ec990dba4e","value":{"title":"My Idea","content":"I have to discuss my idea with the team"}},
{"id":"0342fde43316bffdea32d0ec990ee122","key":"0342fde43316bffdea32d0ec990ee122","value":{"title":"New project","content":"I need to call the customer"}},
{"id":"0342fde43316bffdea32d0ec990f168c","key":"0342fde43316bffdea32d0ec990f168c","value":{"title":"Birth day","content":"Buy a gift for my mom!"}}

]}

【问题讨论】:

    标签: android http get android-volley


    【解决方案1】:

    你可以使用这个link

    final String URL = "/volley/resource/12";
    // Post params to be sent to the server
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("token", "AbCdEfGh123456");
    
    JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(params),
           new Response.Listener<JSONObject>() {
               @Override
               public void onResponse(JSONObject response) {
                   try {
                       VolleyLog.v("Response:%n %s", response.toString(4));
                   } catch (JSONException e) {
                       e.printStackTrace();
                   }
               }
           }, new Response.ErrorListener() {
               @Override
               public void onErrorResponse(VolleyError error) {
                   VolleyLog.e("Error: ", error.getMessage());
               }
           });
    
    // add the request object to the queue to be executed
    ApplicationController.getInstance().addToRequestQueue(req);
    

    【讨论】:

      猜你喜欢
      • 2020-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-28
      • 2012-11-03
      • 1970-01-01
      相关资源
      最近更新 更多