如何使用 Volley 以这种 JSON 格式发出 Http get 请求
How can I make Http get request using Volley on this JSON format
重要提示:所有 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!"}}
]}
你可以用这个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);
重要提示:所有 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!"}}
]}
你可以用这个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);