Savage F. Morgan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

sonObjectRequest actuallyaccepts JSONObject as body.

From http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/

final String url = "some/url";
final JSONObject jsonBody = /* ... */;

new JsonObjectRequest(url, jsonBody, new Response.Listener<JSONObject>() { ... });

Here is the offical code and javadoc (@param jsonRequest):

/**
 * Creates a new request.
 * @param method the HTTP method to use
 * @param url URL to fetch the JSON from
 * @param jsonRequest A {@link JSONObject} to post with the request. Null is allowed and
 *   indicates no parameters will be posted along with request.
 * @param listener Listener to receive the JSON response
 * @param errorListener Error listener, or null to ignore errors.
 */
public JsonObjectRequest(int method, String url, JSONObject jsonRequest,
        Listener<JSONObject> listener, ErrorListener errorListener) {
    super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
                errorListener);
}
 
posted on 2014-06-20 17:26  罗斯摩根  阅读(1263)  评论(0编辑  收藏  举报