public abstract class

JsonRequest

extends Request<T>
java.lang.Object
   ↳ com.android.volley.Request<T>
     ↳ com.android.volley.toolbox.JsonRequest<T>
Known Direct Subclasses

Class Overview

A request for retrieving a T type response body at a given URL that also optionally sends along a JSON body in the request specified.

Summary

Constants
String PROTOCOL_CHARSET Default charset for JSON request.
Public Constructors
JsonRequest(String url, String requestBody, Listener<T> listener, Response.ErrorListener errorListener)
This constructor is deprecated. Use JsonRequest(int, String, String, Listener, ErrorListener).
JsonRequest(int method, String url, String requestBody, Listener<T> listener, Response.ErrorListener errorListener)
Public Methods
byte[] getBody()
Returns the raw POST or PUT body to be sent.
String getBodyContentType()
Returns the content type of the POST or PUT body.
byte[] getPostBody()
This method is deprecated. Use getBody().
String getPostBodyContentType()
This method is deprecated. Use getBodyContentType().
Protected Methods
void deliverResponse(T response)
Subclasses must implement this to perform delivery of the parsed response to their listeners.
abstract Response<T> parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response and return an appropriate response type.
[Expand]
Inherited Methods
From class com.android.volley.Request
From class java.lang.Object
From interface java.lang.Comparable

Constants

protected static final String PROTOCOL_CHARSET

Default charset for JSON request.

Constant Value: "utf-8"

Public Constructors

public JsonRequest (String url, String requestBody, Listener<T> listener, Response.ErrorListener errorListener)

This constructor is deprecated.
Use JsonRequest(int, String, String, Listener, ErrorListener).

Deprecated constructor for a JsonRequest which defaults to GET unless getPostBody() or getPostParams() is overridden (which defaults to POST).

public JsonRequest (int method, String url, String requestBody, Listener<T> listener, Response.ErrorListener errorListener)

Public Methods

public byte[] getBody ()

Returns the raw POST or PUT body to be sent.

By default, the body consists of the request parameters in application/x-www-form-urlencoded format. When overriding this method, consider overriding getBodyContentType() as well to match the new body format.

public String getBodyContentType ()

Returns the content type of the POST or PUT body.

public byte[] getPostBody ()

This method is deprecated.
Use getBody().

Returns the raw POST body to be sent.

public String getPostBodyContentType ()

This method is deprecated.
Use getBodyContentType().

Protected Methods

protected void deliverResponse (T response)

Subclasses must implement this to perform delivery of the parsed response to their listeners. The given response is guaranteed to be non-null; responses that fail to parse are not delivered.

Parameters
response The parsed response returned by parseNetworkResponse(NetworkResponse)

protected abstract Response<T> parseNetworkResponse (NetworkResponse response)

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.

Parameters
response Response from the network
Returns
  • The parsed response, or null in the case of an error