Package blue.endless.jankson
Class JsonPrimitive
java.lang.Object
blue.endless.jankson.JsonElement
blue.endless.jankson.JsonPrimitive
- All Implemented Interfaces:
Cloneable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic JsonPrimitiveConvenience instance of json "false".static JsonPrimitiveConvenience instance of json "true". -
Constructor Summary
ConstructorsConstructorDescriptionJsonPrimitive(Object value) Creates a new JsonPrimitive node representing the passed-in value. -
Method Summary
Modifier and TypeMethodDescriptionasBigDecimal(BigDecimal defaultValue) asBigInteger(BigInteger defaultValue) booleanasBoolean(boolean defaultValue) byteasByte(byte defaultValue) charasChar(char defaultValue) doubleasDouble(double defaultValue) floatasFloat(float defaultValue) intasInt(int defaultValue) longasLong(long defaultValue) shortasShort(short defaultValue) asString()clone()booleangetValue()inthashCode()static JsonPrimitivestatic JsonPrimitivestatic JsonPrimitivestatic JsonPrimitivestatic JsonPrimitiveof(BigDecimal n) static JsonPrimitiveof(BigInteger n) toJson(boolean comments, boolean newlines, int depth) voidtoJson(Writer writer, JsonGrammar grammar, int depth) toString()Methods inherited from class blue.endless.jankson.JsonElement
toJson, toJson, toJson, toJson
-
Field Details
-
TRUE
Convenience instance of json "true". Don't use identity comparison (==) on these! Use equals instead. -
FALSE
Convenience instance of json "false". Don't use identity comparison (==) on these! Use equals instead.
-
-
Constructor Details
-
JsonPrimitive
Creates a new JsonPrimitive node representing the passed-in value.Note: This constructor may do expensive type inspection to verify that the passed-in object is well-formed. Please use one of the JsonPrimitive.of(x) static factory variants if possible, because using function polymorphism often winds up validating the results "for free".
- Parameters:
value-
-
-
Method Details
-
asString
-
asBoolean
public boolean asBoolean(boolean defaultValue) -
asByte
public byte asByte(byte defaultValue) -
asChar
public char asChar(char defaultValue) -
asShort
public short asShort(short defaultValue) -
asInt
public int asInt(int defaultValue) -
asLong
public long asLong(long defaultValue) -
asFloat
public float asFloat(float defaultValue) -
asDouble
public double asDouble(double defaultValue) -
asBigInteger
-
asBigDecimal
-
toString
-
getValue
-
equals
-
hashCode
public int hashCode() -
toJson
- Specified by:
toJsonin classJsonElement
-
toJson
- Specified by:
toJsonin classJsonElement- Throws:
IOException
-
clone
- Specified by:
clonein classJsonElement
-
of
-
of
-
of
-
of
-
of
-
of
-