com.android.volley.toolbox
Class JsonObjectRequest

java.lang.Object
  extended by com.android.volley.Request<T>
      extended by com.android.volley.toolbox.JsonRequest<JSONObject>
          extended by com.android.volley.toolbox.JsonObjectRequest
All Implemented Interfaces:
Comparable<Request<JSONObject>>

public class JsonObjectRequest
extends JsonRequest<JSONObject>

A request for retrieving a JSONObject response body at a given URL, allowing for an optional JSONObject to be passed in as part of the request body.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.volley.Request
Request.Method, Request.Priority
 
Constructor Summary
JsonObjectRequest(int method, String url, JSONObject jsonRequest, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener)
          Creates a new request.
JsonObjectRequest(String url, JSONObject jsonRequest, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener)
          Constructor which defaults to GET if jsonRequest is null, POST otherwise.
 
Method Summary
protected  Response<JSONObject> parseNetworkResponse(NetworkResponse response)
          Subclasses must implement this to parse the raw network response and return an appropriate response type.
 
Methods inherited from class com.android.volley.toolbox.JsonRequest
deliverResponse, getBody, getBodyContentType, getPostBody, getPostBodyContentType
 
Methods inherited from class com.android.volley.Request
addMarker, cancel, compareTo, deliverError, getCacheEntry, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonObjectRequest

public JsonObjectRequest(int method,
                         String url,
                         JSONObject jsonRequest,
                         Response.Listener<JSONObject> listener,
                         Response.ErrorListener errorListener)
Creates a new request.

Parameters:
method - the HTTP method to use
url - URL to fetch the JSON from
jsonRequest - A JSONObject to post with the request. Null is allowed and indicates no parameters will be posted along with request.
listener - Listener to receive the JSON response
errorListener - Error listener, or null to ignore errors.

JsonObjectRequest

public JsonObjectRequest(String url,
                         JSONObject jsonRequest,
                         Response.Listener<JSONObject> listener,
                         Response.ErrorListener errorListener)
Constructor which defaults to GET if jsonRequest is null, POST otherwise.

See Also:
#JsonObjectRequest(int, String, JSONObject, Listener, ErrorListener)
Method Detail

parseNetworkResponse

protected Response<JSONObject> parseNetworkResponse(NetworkResponse response)
Description copied from class: Request
Subclasses must implement this to parse the raw network response and return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.

Specified by:
parseNetworkResponse in class JsonRequest<JSONObject>
Parameters:
response - Response from the network
Returns:
The parsed response, or null in the case of an error