| java.lang.Object | ||
| ↳ | com.google.gson.JsonElement | |
| ↳ | com.google.gson.JsonPrimitive | |
A class representing a Json primitive value. A primitive value is either a String, a Java primitive, or a Java primitive wrapper type.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
JsonPrimitive(Boolean bool)
Create a primitive containing a boolean value.
| |||||||||||
|
JsonPrimitive(Number number)
Create a primitive containing a
Number. | |||||||||||
|
JsonPrimitive(String string)
Create a primitive containing a String value.
| |||||||||||
|
JsonPrimitive(Character c)
Create a primitive containing a character.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean | equals(Object obj) | ||||||||||
| 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.
| ||||||||||
| float |
getAsFloat()
convenience method to get this element as a float.
| ||||||||||
| int |
getAsInt()
convenience method to get this element as a primitive integer.
| ||||||||||
| long |
getAsLong()
convenience method to get this element as a primitive long.
| ||||||||||
| Number |
getAsNumber()
convenience method to get this element as a Number.
| ||||||||||
| short |
getAsShort()
convenience method to get this element as a primitive short.
| ||||||||||
| String |
getAsString()
convenience method to get this element as a String.
| ||||||||||
| int | hashCode() | ||||||||||
| boolean |
isBoolean()
Check whether this primitive contains a boolean value.
| ||||||||||
| boolean |
isNumber()
Check whether this primitive contains a Number.
| ||||||||||
| boolean |
isString()
Check whether this primitive contains a String value.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gson.JsonElement
| |||||||||||
From class
java.lang.Object
| |||||||||||
Create a primitive containing a boolean value.
| bool | the value to create the primitive with. |
|---|
Create a primitive containing a Number.
| number | the value to create the primitive with. |
|---|
Create a primitive containing a String value.
| string | the value to create the primitive with. |
|---|
Create a primitive containing a character. The character is turned into a one character String since Json only supports String.
| c | the value to create the primitive with. |
|---|
convenience method to get this element as a BigDecimal.
BigDecimal.| NumberFormatException | if the value contained is not a valid BigDecimal.
|
|---|
convenience method to get this element as a BigInteger.
BigInteger.| NumberFormatException | if the value contained is not a valid BigInteger.
|
|---|
convenience method to get this element as a boolean value.
convenience method to get this element as a primitive byte value.
convenience method to get this element as a primitive character value.
convenience method to get this element as a primitive double.
| NumberFormatException | if the value contained is not a valid double. |
|---|
convenience method to get this element as a float.
| NumberFormatException | if the value contained is not a valid float. |
|---|
convenience method to get this element as a primitive integer.
| NumberFormatException | if the value contained is not a valid integer. |
|---|
convenience method to get this element as a primitive long.
| NumberFormatException | if the value contained is not a valid long. |
|---|
convenience method to get this element as a Number.
| NumberFormatException | if the value contained is not a valid Number. |
|---|
convenience method to get this element as a primitive short.
| NumberFormatException | if the value contained is not a valid short value. |
|---|
convenience method to get this element as a String.
Check whether this primitive contains a boolean value.
Check whether this primitive contains a Number.
Check whether this primitive contains a String value.