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
Modifier and TypeClassDescriptionstatic enum
The ToString format.static class
Alias class of json arrays.static class
Alias class of whatever is used to store json maps (objects).static class
An unchecked exception to indicate that an input does not qualify as valid JSON.static enum
Defines the known json types. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(boolean value) void
void
asArray()
boolean
asBool()
double
asDouble()
float
asFloat()
int
asInt()
long
asLong()
asNumber()
asObject()
asString()
boolean
boolean
double
float
int
long
getType()
boolean
boolean
isArray()
boolean
boolean
isFalse()
boolean
isNull()
boolean
isNumber()
boolean
isObject()
boolean
isString()
boolean
isTrue()
static Jval
newArray()
static Jval
static Jval
read
(byte[] bytes) static Jval
Reads a Hjson value from the given reader.static Jval
Reads 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 Jval
valueOf
(boolean value) static Jval
valueOf
(double value) static Jval
valueOf
(float value) static Jval
valueOf
(int value) static Jval
valueOf
(long value) static Jval
void
Writes the JSON representation of this value to the given writer in its minimal form, without any additional whitespace.void
writeTo
(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
BufferedReader
does 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
-