public class JsonReader
extends java.lang.Object
| Constructor and Description |
|---|
JsonReader(com.google.gson.JsonElement element)
A json reader.
|
JsonReader(java.lang.String json)
A json reader.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.gson.JsonElement |
asJson()
Deserialize the returned Json string.
|
<T> T |
asJson(java.lang.Class<T> type)
Deserialize the Json into an object of the specified class.
|
<T> T |
asJson(java.lang.reflect.Type type)
Deserialize the Json into an object of the specified class.
|
java.lang.String |
asPrettyString() |
com.google.gson.JsonElement |
jsonPath(com.google.gson.JsonElement json,
java.lang.String path)
Search a JSON element's children for the requested element.
|
com.google.gson.JsonElement |
jsonPath(java.lang.String path)
Search the JSON response for the requested element.
|
public JsonReader(java.lang.String json)
json - Json stringJsonParseException - JsonParseExceptionpublic JsonReader(com.google.gson.JsonElement element)
element - Json Elementpublic java.lang.String asPrettyString()
throws java.io.IOException
java.io.IOException - If unable to read the responsepublic com.google.gson.JsonElement asJson()
throws java.io.IOException
JsonElementjava.io.IOException - if the response string is not valid JSONpublic com.google.gson.JsonElement jsonPath(java.lang.String path)
JsonElement value = reader.jsonPath("anArray[0].aValue").
String details = (value == null ? "" : value.getAsString());
path - Json pathpublic com.google.gson.JsonElement jsonPath(com.google.gson.JsonElement json,
java.lang.String path)
json - Json elementpath - search pathpublic <T> T asJson(java.lang.Class<T> type)
throws java.io.IOException
T - The type of the desired objecttype - Class to populatejava.io.IOException - if json is not a valid representation for an object of type classOfTpublic <T> T asJson(java.lang.reflect.Type type)
throws com.google.gson.JsonSyntaxException
T - The type of the desired objecttype - Class to populatejava.io.IOException - if json is not a valid representation for an object of type classOfTcom.google.gson.JsonSyntaxException