Package arc.util.serialization
Class Jval
java.lang.Object
arc.util.serialization.Jval
An hsjon parser. Can be used as a standard json value.
Output can be converted to standard JSON. This class is heavily based upon the Hjson Java implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe ToString format.static classAlias class of json arrays.static classAlias class of whatever is used to store json maps (objects).static classAn unchecked exception to indicate that an input does not qualify as valid JSON.static enumDefines the known json types. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionadd(boolean value) voidvoidasArray()booleanasBool()doubleasDouble()floatasFloat()intasInt()longasLong()asNumber()asObject()asString()booleanbooleandoublefloatintlonggetType()booleanbooleanisArray()booleanbooleanisFalse()booleanisNull()booleanisNumber()booleanisObject()booleanisString()booleanisTrue()static JvalnewArray()static Jvalstatic Jvalread(byte[] bytes) static JvalReads a Hjson value from the given reader.static JvalReads a Hjson value from the given string.toString()Returns the JSON string for this value in its minimal form, without any additional whitespace.toString(Jval.Jformat format) Returns the JSON/Hjson string for this value using the given formatting.static JvalvalueOf(boolean value) static JvalvalueOf(double value) static JvalvalueOf(float value) static JvalvalueOf(int value) static JvalvalueOf(long value) static JvalvoidWrites the JSON representation of this value to the given writer in its minimal form, without any additional whitespace.voidwriteTo(Writer writer, Jval.Jformat format) Writes the JSON/Hjson representation of this value to the given writer using the given formatting.
-
Field Details
-
TRUE
-
FALSE
-
NULL
-
-
Method Details
-
newObject
-
newArray
-
read
Reads a Hjson value from the given reader.Characters are read in chunks and buffered internally, therefore wrapping an existing reader in an additional
BufferedReaderdoes not improve reading performance.- Parameters:
reader- the reader to read the Hjson value from- Returns:
- the Hjson value that has been read
-
read
-
read
Reads a Hjson value from the given string.- Parameters:
text- the string that contains the Hjson value- Returns:
- the Hjson value that has been read
-
getType
-
valueOf
-
valueOf
-
valueOf
-
valueOf
-
valueOf
-
valueOf
-
isObject
public boolean isObject() -
isArray
public boolean isArray() -
isNumber
public boolean isNumber() -
isString
public boolean isString() -
isBoolean
public boolean isBoolean() -
isTrue
public boolean isTrue() -
isFalse
public boolean isFalse() -
isNull
public boolean isNull() -
asObject
-
asArray
-
asInt
public int asInt() -
asLong
public long asLong() -
asFloat
public float asFloat() -
asDouble
public double asDouble() -
asString
-
asBool
public boolean asBool() -
asNumber
-
get
-
add
-
add
-
add
-
add
-
add
-
add
-
put
-
put
-
put
-
put
-
remove
-
has
-
getInt
-
getLong
-
getFloat
-
getDouble
-
getBool
-
getString
-
getString
-
writeTo
Writes the JSON representation of this value to the given writer in its minimal form, without any additional whitespace.Writing performance can be improved by using a
BufferedWriter.- Parameters:
writer- the writer to write this value to- Throws:
IOException- if an I/O error occurs in the writer
-
writeTo
Writes the JSON/Hjson representation of this value to the given writer using the given formatting.Writing performance can be improved by using a
BufferedWriter.- Parameters:
writer- the writer to write this value toformat- controls the formatting- Throws:
IOException- if an I/O error occurs in the writer
-
toString
Returns the JSON string for this value in its minimal form, without any additional whitespace. -
toString
Returns the JSON/Hjson string for this value using the given formatting.- Parameters:
format- controls the formatting- Returns:
- a JSON/Hjson string that represents this value
-
equals
-