FileDocCategorySizeDatePackage
JsonObjectRequest.javaAPI DocAndroid 5.1 API3028Thu Mar 12 22:22:56 GMT 2015com.android.volley.toolbox

JsonObjectRequest

public class JsonObjectRequest extends JsonRequest
A request for retrieving a {@link JSONObject} response body at a given URL, allowing for an optional {@link JSONObject} to be passed in as part of the request body.

Fields Summary
Constructors Summary
public JsonObjectRequest(int method, String url, JSONObject jsonRequest, com.android.volley.Response.Listener listener, com.android.volley.Response.ErrorListener errorListener)
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.

        super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
                    errorListener);
    
public JsonObjectRequest(String url, JSONObject jsonRequest, com.android.volley.Response.Listener listener, com.android.volley.Response.ErrorListener errorListener)
Constructor which defaults to GET if jsonRequest is null, POST otherwise.

see
#JsonObjectRequest(int, String, JSONObject, Listener, ErrorListener)

        this(jsonRequest == null ? Method.GET : Method.POST, url, jsonRequest,
                listener, errorListener);
    
Methods Summary
protected com.android.volley.ResponseparseNetworkResponse(com.android.volley.NetworkResponse response)

        try {
            String jsonString =
                new String(response.data, HttpHeaderParser.parseCharset(response.headers));
            return Response.success(new JSONObject(jsonString),
                    HttpHeaderParser.parseCacheHeaders(response));
        } catch (UnsupportedEncodingException e) {
            return Response.error(new ParseError(e));
        } catch (JSONException je) {
            return Response.error(new ParseError(je));
        }