| java.lang.Object | |
| ↳ | com.google.gson.JsonElement |
Known Direct Subclasses
|
A class representing an element of Json. It could either be a JsonObject, a
JsonArray, a JsonPrimitive or a JsonNull.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| JsonElement() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| BigDecimal |
getAsBigDecimal()
convenience method to get this element as a
BigDecimal. | ||||||||||
| BigInteger |
getAsBigInteger()
convenience method to get this element as a
BigInteger. | ||||||||||
| boolean |
getAsBoolean()
convenience method to get this element as a boolean value.
| ||||||||||
| byte |
getAsByte()
convenience method to get this element as a primitive byte value.
| ||||||||||
| char |
getAsCharacter()
convenience method to get this element as a primitive character value.
| ||||||||||
| double |
getAsDouble()
convenience method to get this element as a primitive double value.
| ||||||||||
| float |
getAsFloat()
convenience method to get this element as a primitive float value.
| ||||||||||
| int |
getAsInt()
convenience method to get this element as a primitive integer value.
| ||||||||||
| JsonArray |
getAsJsonArray()
convenience method to get this element as a
JsonArray. | ||||||||||
| JsonNull |
getAsJsonNull()
convenience method to get this element as a
JsonNull. | ||||||||||
| JsonObject |
getAsJsonObject()
convenience method to get this element as a
JsonObject. | ||||||||||
| JsonPrimitive |
getAsJsonPrimitive()
convenience method to get this element as a
JsonPrimitive. | ||||||||||
| long |
getAsLong()
convenience method to get this element as a primitive long value.
| ||||||||||
| Number |
getAsNumber()
convenience method to get this element as a
Number. | ||||||||||
| short |
getAsShort()
convenience method to get this element as a primitive short value.
| ||||||||||
| String |
getAsString()
convenience method to get this element as a string value.
| ||||||||||
| boolean |
isJsonArray()
provides check for verifying if this element is an array or not.
| ||||||||||
| boolean |
isJsonNull()
provides check for verifying if this element represents a null value or not.
| ||||||||||
| boolean |
isJsonObject()
provides check for verifying if this element is a Json object or not.
| ||||||||||
| boolean |
isJsonPrimitive()
provides check for verifying if this element is a primitive or not.
| ||||||||||
| String |
toString()
Returns a String representation of this element.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
convenience method to get this element as a BigDecimal.
BigDecimal.| ClassCastException | if the element is of not a JsonPrimitive.
* @throws NumberFormatException if the element is not a valid BigDecimal. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element. |
convenience method to get this element as a BigInteger.
BigInteger.| ClassCastException | if the element is of not a JsonPrimitive. |
|---|---|
| NumberFormatException | if the element is not a valid BigInteger. |
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element. |
convenience method to get this element as a boolean value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
boolean value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a primitive byte value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
byte value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element. |
convenience method to get this element as a primitive character value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
char value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element. |
convenience method to get this element as a primitive double value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
double value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a primitive float value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
float value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a primitive integer value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
integer value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a JsonArray. If the element is of some
other type, a ClassCastException will result. Hence it is best to use this method
after ensuring that this element is of the desired type by calling isJsonArray()
first.
JsonArray.| IllegalStateException | if the element is of another type. |
|---|
convenience method to get this element as a JsonNull. If the element is of some
other type, a ClassCastException will result. Hence it is best to use this method
after ensuring that this element is of the desired type by calling isJsonNull()
first.
JsonNull.| IllegalStateException | if the element is of another type. |
|---|
convenience method to get this element as a JsonObject. If the element is of some
other type, a ClassCastException will result. Hence it is best to use this method
after ensuring that this element is of the desired type by calling isJsonObject()
first.
JsonObject.| IllegalStateException | if the element is of another type. |
|---|
convenience method to get this element as a JsonPrimitive. If the element is of some
other type, a ClassCastException will result. Hence it is best to use this method
after ensuring that this element is of the desired type by calling isJsonPrimitive()
first.
JsonPrimitive.| IllegalStateException | if the element is of another type. |
|---|
convenience method to get this element as a primitive long value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
long value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a Number.
Number.| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
number. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a primitive short value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
short value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
convenience method to get this element as a string value.
| ClassCastException | if the element is of not a JsonPrimitive and is not a valid
string value. |
|---|---|
| IllegalStateException | if the element is of the type JsonArray but contains
more than a single element.
|
provides check for verifying if this element is an array or not.
JsonArray, false otherwise.
provides check for verifying if this element represents a null value or not.
JsonNull, false otherwise.provides check for verifying if this element is a Json object or not.
JsonObject, false otherwise.
provides check for verifying if this element is a primitive or not.
JsonPrimitive, false otherwise.