com.google.api.client.googleapis.json
Class JsonCParser
java.lang.Object
com.google.api.client.http.json.JsonHttpParser
com.google.api.client.googleapis.json.JsonCParser
- All Implemented Interfaces:
- HttpParser
public final class JsonCParser
- extends JsonHttpParser
Parses HTTP JSON-C response content into an data class of key/value pairs, assuming the data is
wrapped in a "data"
envelope.
Warning: this should only be used by some older Google APIs that wrapped the response in a "data"
envelope. All newer Google APIs don't use this envelope, and for those APIs
JsonHttpParser
should be used instead.
Sample usage:
static void setParser(HttpRequest request) {
request.addParser(new JsonCParser(new JacksonFactory()));
}
Implementation is thread-safe.
- Since:
- 1.0
- Author:
- Yaniv Inbar
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonCParser
public JsonCParser(JsonFactory jsonFactory)
- Parameters:
jsonFactory
- JSON factory- Since:
- 1.5
parse
public <T> T parse(HttpResponse response,
Class<T> dataClass)
throws IOException
- Specified by:
parse
in interface HttpParser
- Overrides:
parse
in class JsonHttpParser
- Throws:
IOException
parserForResponse
public static JsonParser parserForResponse(JsonFactory jsonFactory,
HttpResponse response)
throws IOException
- Returns a JSON parser to use for parsing the given HTTP response, skipped over the
"data"
envelope.
The parser will be closed if any throwable is thrown. The current token will be the value of
the "data"
key.
- Parameters:
response
- HTTP response
- Returns:
- JSON parser
- Throws:
IllegalArgumentException
- if content type is not Json.CONTENT_TYPE
or if
expected "data"
or "error"
key is not found
IOException
- I/O exception- Since:
- 1.3
Copyright © 2010-2012 Google. All Rights Reserved.