object Json
This class serves as the entry point to the minimal-json API.
To parse a given JSON input, use the parse()
methods like in this
example:
To create a JSON data structure to be serialized, use the methods
value()
, array()
, and object()
. For example, the following
snippet will produce the JSON string {"foo": 23, "bar": true}:
To create a JSON array from a given Java array, you can use one of the array()
methods with varargs parameters:
val FALSE: JsonValue
Represents the JSON literal |
|
val NULL: JsonValue
Represents the JSON literal |
|
val TRUE: JsonValue
Represents the JSON literal |
fun array(): JsonArray
Creates a new empty JsonArray. This is equivalent to creating a new JsonArray using the constructor. fun array(vararg values: Int): JsonArray
Creates a new JsonArray that contains the JSON representations of the given fun array(vararg values: Long): JsonArray
Creates a new JsonArray that contains the JSON representations of the given fun array(vararg values: Float): JsonArray
Creates a new JsonArray that contains the JSON representations of the given fun array(vararg values: Double): JsonArray
Creates a new JsonArray that contains the JSON representations of the given fun array(vararg values: Boolean): JsonArray
Creates a new JsonArray that contains the JSON representations of the given
fun array(vararg strings: String): JsonArray
Creates a new JsonArray that contains the JSON representations of the given strings. |
|
fun object(): JsonObject
Creates a new empty JsonObject. This is equivalent to creating a new JsonObject using the constructor. |
|
fun parse(string: String): JsonValue
Parses the given input string as JSON. The input must contain a valid JSON value, optionally padded with whitespace. fun parse(reader: Reader): JsonValue
Reads the entire input from the given reader and parses it as JSON. The input must contain a valid JSON value, optionally padded with whitespace. |
|
fun value(value: Int): JsonValue
Returns a JsonValue instance that represents the given fun value(value: Long): JsonValue
Returns a JsonValue instance that represents the given fun value(value: Float): JsonValue
Returns a JsonValue instance that represents the given fun value(value: Double): JsonValue
Returns a JsonValue instance that represents the given fun value(string: String?): JsonValue
Returns a JsonValue instance that represents the given string. fun value(value: Boolean): JsonValue
Returns a JsonValue instance that represents the given |