See the JsonElement documentation for details on how to convert JsonPrimitive
and generally any JsonElement from and to JSON.
| Access | Constructor and Description |
|---|---|
| public | JsonPrimitive(Boolean
the value to create the primitive with. bool)Create a primitive containing a boolean value. |
| public | JsonPrimitive(Number
the value to create the primitive with. number)Create a primitive containing a |
| public | JsonPrimitive(String
the value to create the primitive with. string)Create a primitive containing a String value. |
| public | JsonPrimitive(Character
the value to create the primitive with. c)Create a primitive containing a character. |
| Modifier and Type | Method and Description |
|---|---|
| public JsonPrimitive | deepCopy()
Implements abstract com. Returns the same value as primitives are immutable. |
| public boolean | equals(Object obj)
Overrides java. Returns whether the other object is equal to this. |
| public BigDecimal | getAsBigDecimal()
Overrides com. Convenience method to get this element as a |
| public BigInteger | getAsBigInteger()
Overrides com. Convenience method to get this element as a |
| public boolean | getAsBoolean()
Overrides com. Convenience method to get this element as a boolean value. |
| public byte | getAsByte()
Overrides com. Convenience method to get this element as a primitive byte value. |
| public char | getAsCharacter()
Overrides com.
Deprecated
This method is misleading, as it does not get this element as a char but rather as
a string's first character.
Convenience method to get the first character of the string value of this element. |
| public double | getAsDouble()
Overrides com. Convenience method to get this element as a primitive double value. |
| public float | getAsFloat()
Overrides com. Convenience method to get this element as a primitive float value. |
| public int | getAsInt()
Overrides com. Convenience method to get this element as a primitive integer value. |
| public long | Returns: this element as a primitive long.Overrides com. Convenience method to get this element as a primitive long. |
| public Number | getAsNumber()
Overrides com. Convenience method to get this element as a |
| public short | getAsShort()
Overrides com. Convenience method to get this element as a primitive short value. |
| public String | getAsString()
Overrides com. Convenience method to get this element as a string value. |
| public int | |
| public boolean | Returns: true if this primitive contains a boolean value, false otherwise.Check whether this primitive contains a boolean value. |
| private static boolean | isIntegral(JsonPrimitive primitive)
Returns true if the specified number is an integral type (Long, Integer, Short, Byte, BigInteger) |
| public boolean | Returns: true if this primitive contains a Number, false otherwise.Check whether this primitive contains a Number. |
| public boolean | Returns: true if this primitive contains a String value, false otherwise.Check whether this primitive contains a String value. |
| value | back to summary |
|---|---|
| private final Object value | |
| JsonPrimitive | back to summary |
|---|---|
| public JsonPrimitive(Boolean bool) Create a primitive containing a boolean value.
| |
| JsonPrimitive | back to summary |
|---|---|
| public JsonPrimitive(Number number) Create a primitive containing a
| |
| JsonPrimitive | back to summary |
|---|---|
| public JsonPrimitive(String string) Create a primitive containing a String value.
| |
| JsonPrimitive | back to summary |
|---|---|
| public JsonPrimitive(Character c) Create a primitive containing a character. The character is turned into a one character String since JSON only supports String.
| |
| deepCopy | back to summary |
|---|---|
| public JsonPrimitive deepCopy() Implements abstract com. Returns the same value as primitives are immutable.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Returns whether the other object is equal to this. This method only considers the other object
to be equal if it is an instance of
| |
| getAsBigDecimal | back to summary |
|---|---|
| public BigDecimal getAsBigDecimal() Overrides com. Doc from com. Convenience method to get this element as a
| |
| getAsBigInteger | back to summary |
|---|---|
| public BigInteger getAsBigInteger() Overrides com. Doc from com. Convenience method to get this element as a
| |
| getAsBoolean | back to summary |
|---|---|
| public boolean getAsBoolean() Overrides com. Convenience method to get this element as a boolean value. If this primitive is not a boolean, the string value is parsed using
| |
| getAsByte | back to summary |
|---|---|
| public byte getAsByte() Overrides com. Doc from com. Convenience method to get this element as a primitive byte value.
| |
| getAsCharacter | back to summary |
|---|---|
| public char getAsCharacter() Overrides com. Doc from com. Deprecated This method is misleading, as it does not get this element as a char but rather as a string's first character. Convenience method to get the first character of the string value of this element.
| |
| getAsDouble | back to summary |
|---|---|
| public double getAsDouble() Overrides com. Doc from com. Convenience method to get this element as a primitive double value.
| |
| getAsFloat | back to summary |
|---|---|
| public float getAsFloat() Overrides com. Doc from com. Convenience method to get this element as a primitive float value.
| |
| getAsInt | back to summary |
|---|---|
| public int getAsInt() Overrides com. Doc from com. Convenience method to get this element as a primitive integer value.
| |
| getAsLong | back to summary |
|---|---|
| public long getAsLong() Overrides com. Convenience method to get this element as a primitive long.
| |
| getAsNumber | back to summary |
|---|---|
| public Number getAsNumber() Overrides com. Convenience method to get this element as a
| |
| getAsShort | back to summary |
|---|---|
| public short getAsShort() Overrides com. Doc from com. Convenience method to get this element as a primitive short value.
| |
| getAsString | back to summary |
|---|---|
| public String getAsString() Overrides com. Doc from com. Convenience method to get this element as a string value.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code of this object.
| |
| isBoolean | back to summary |
|---|---|
| public boolean isBoolean() Check whether this primitive contains a boolean value.
| |
| isIntegral | back to summary |
|---|---|
| private static boolean isIntegral(JsonPrimitive primitive) Returns true if the specified number is an integral type (Long, Integer, Short, Byte, BigInteger) | |
| isNumber | back to summary |
|---|---|
| public boolean isNumber() Check whether this primitive contains a Number.
| |
| isString | back to summary |
|---|---|
| public boolean isString() Check whether this primitive contains a String value.
| |