|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.client.http.json.JsonHttpParser
public class JsonHttpParser
Parses HTTP JSON response content into an data class of key/value pairs.
Sample usage:
static void setParser(HttpTransport transport) {
JsonHttpParser parser = new JsonHttpParser();
parser.jsonFactory = new JacksonFactory();
transport.addParser(parser);
}
| Field Summary | |
|---|---|
String |
contentType
Content type. |
JsonFactory |
jsonFactory
(Required) JSON factory to use. |
| Constructor Summary | |
|---|---|
JsonHttpParser()
|
|
| Method Summary | ||
|---|---|---|
String |
getContentType()
Returns the content type. |
|
|
parse(HttpResponse response,
Class<T> dataClass)
Parses the given HTTP response into a new instance of the the given data class of key/value pairs. |
|
static JsonParser |
parserForResponse(JsonFactory jsonFactory,
HttpResponse response)
Returns a JSON parser to use for parsing the given HTTP response. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public String contentType
Json.CONTENT_TYPE.
public JsonFactory jsonFactory
| Constructor Detail |
|---|
public JsonHttpParser()
| Method Detail |
|---|
public final String getContentType()
HttpParser
getContentType in interface HttpParser
public <T> T parse(HttpResponse response,
Class<T> dataClass)
throws IOException
HttpParser
How the parsing is performed is not restricted by this interface, and is instead defined by the
concrete implementation. Implementations should check HttpResponse.isSuccessStatusCode
to know whether they are parsing a success or error response.
parse in interface HttpParserIOException
public static JsonParser parserForResponse(JsonFactory jsonFactory,
HttpResponse response)
throws IOException
The response content will be closed if any throwable is thrown. On success, the current token
will be the first top token, which is normally JsonToken.START_ARRAY or
JsonToken.START_OBJECT.
jsonFactory - JSON factory to useresponse - HTTP response
IllegalArgumentException - if content type is not Json.CONTENT_TYPE
IOException - I/O exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||