|
||||||||||
| 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
com.google.api.client.googleapis.json.JsonCParser
public final class JsonCParser
Parses 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
JsonObjectParser should be used instead.
Sample usage:
static void setParser(HttpRequest request) {
request.setParser(new JsonCParser(new JacksonFactory()));
}
Implementation is thread-safe.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.google.api.client.http.json.JsonHttpParser |
|---|
JsonHttpParser.Builder |
| Constructor Summary | |
|---|---|
JsonCParser(JsonFactory jsonFactory)
|
|
| Method Summary | ||
|---|---|---|
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. |
|
|
parse(HttpResponse response,
Class<T> dataClass)
Deprecated. |
|
|
parseAndClose(InputStream in,
Charset charset,
Class<T> dataClass)
|
|
Object |
parseAndClose(InputStream in,
Charset charset,
Type dataType)
|
|
|
parseAndClose(Reader reader,
Class<T> dataClass)
|
|
Object |
parseAndClose(Reader reader,
Type dataType)
|
|
static JsonParser |
parserForResponse(JsonFactory jsonFactory,
HttpResponse response)
Deprecated. (scheduled to be removed in 1.11) Use JsonFactory.createJsonParser(
java.io.InputStream, java.nio.charset.Charset) and initializeParser(JsonParser) instead. |
|
| Methods inherited from class com.google.api.client.http.json.JsonHttpParser |
|---|
builder, getContentType, getJsonFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JsonCParser(JsonFactory jsonFactory)
jsonFactory - non-null JSON factory used for parsing| Method Detail |
|---|
public final JsonFactory getFactory()
@Deprecated
public <T> T parse(HttpResponse response,
Class<T> dataClass)
throws IOException
parse in interface HttpParserparse in class JsonHttpParserIOException
@Deprecated
public static JsonParser parserForResponse(JsonFactory jsonFactory,
HttpResponse response)
throws IOException
JsonFactory.createJsonParser(
java.io.InputStream, java.nio.charset.Charset) and initializeParser(JsonParser) instead.
"data" envelope.
The parser will be closed if any throwable is thrown. The current token will be the value of
the "data" key.
response - HTTP response
IllegalArgumentException - if content type is not Json.CONTENT_TYPE or if
expected "data" or "error" key is not found
IOException - I/O exception
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 parsing
IllegalArgumentException - if content type is not Json.MEDIA_TYPE or if
expected "data" or "error" key is not found
IOException
public <T> T parseAndClose(InputStream in,
Charset charset,
Class<T> dataClass)
throws IOException
parseAndClose in interface ObjectParserIOException
public Object parseAndClose(InputStream in,
Charset charset,
Type dataType)
throws IOException
parseAndClose in interface ObjectParserIOException
public <T> T parseAndClose(Reader reader,
Class<T> dataClass)
throws IOException
parseAndClose in interface ObjectParserIOException
public Object parseAndClose(Reader reader,
Type dataType)
throws IOException
parseAndClose in interface ObjectParserIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||