public final class JsonCParser extends JsonObjectParser
"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
JsonObjectParser should be used instead.
Sample usage:
static void setParser(HttpRequest request) {
request.setParser(new JsonCParser(new JacksonFactory()));
}
Implementation is thread-safe.
Upgrade warning: this class now extends JsonObjectParser, whereas in prior version 1.11
it extended JsonHttpParser.
| Constructor and Description |
|---|
JsonCParser(JsonFactory jsonFactory) |
| Modifier and Type | Method and Description |
|---|---|
JsonFactory |
getFactory()
Returns the JSON factory used for parsing.
|
static JsonParser |
initializeParser(JsonParser parser)
Initializes a JSON parser to use for parsing by skipping over the
"data" or
"error" envelope. |
Object |
parseAndClose(InputStream in,
Charset charset,
Type dataType) |
Object |
parseAndClose(Reader reader,
Type dataType) |
getJsonFactory, parseAndClose, parseAndClosepublic JsonCParser(JsonFactory jsonFactory)
jsonFactory - non-null JSON factory used for parsingpublic final JsonFactory getFactory()
public static JsonParser initializeParser(JsonParser parser) throws IOException
"data" or
"error" envelope.
The parser will be closed if any throwable is thrown. The current token will be the value of
the "data" or "error key.
parser - the parser which should be initialized for normal parsingIllegalArgumentException - if content type is not Json.MEDIA_TYPE or if expected
"data" or "error" key is not foundIOExceptionpublic Object parseAndClose(InputStream in, Charset charset, Type dataType) throws IOException
parseAndClose in interface ObjectParserparseAndClose in class JsonObjectParserIOExceptionpublic Object parseAndClose(Reader reader, Type dataType) throws IOException
parseAndClose in interface ObjectParserparseAndClose in class JsonObjectParserIOExceptionCopyright © 2010-2012 Google. All Rights Reserved.