abstract class JsonValue
Represents a JSON value. This can be a JSON object, an array, a number, a string, or one of the literals true, false, and null.
The literals true, false, and null are represented by the constants Json.TRUE, Json.FALSE, and Json.NULL.
JSON objects and arrays are represented by the subtypes JsonObject and JsonArray. Instances of these types can be created using the public constructors of these classes.
Instances that represent JSON numbers, strings and boolean values can be created using the static factory methods Json.value, Json.value, Json.value, etc.
In order to find out whether an instance of this class is of a certain type, the methods .isObject, .isArray, .isString, .isNumber etc. can be used.
If the type of a JSON value is known, the methods .asObject, .asArray, .asString, .asInt, etc. can be used to get this value directly in the appropriate target type.
This class is not supposed to be extended by clients.
open val isArray: Boolean
Detects whether this value represents a JSON array. If this is the case, this value is an instance of JsonArray. |
|
open val isBoolean: Boolean
Detects whether this value represents a boolean value. |
|
open val isFalse: Boolean
Detects whether this value represents the JSON literal |
|
open val isNull: Boolean
Detects whether this value represents the JSON literal |
|
open val isNumber: Boolean
Detects whether this value represents a JSON number. |
|
open val isObject: Boolean
Detects whether this value represents a JSON object. If this is the case, this value is an instance of JsonObject. |
|
open val isString: Boolean
Detects whether this value represents a JSON string. |
|
open val isTrue: Boolean
Detects whether this value represents the JSON literal |
open fun asArray(): JsonArray
Returns this JSON value as JsonArray, assuming that this value represents a JSON array. If this is not the case, an exception is thrown. |
|
open fun asBoolean(): Boolean
Returns this JSON value as a |
|
open fun asDouble(): Double
Returns this JSON value as a |
|
open fun asFloat(): Float
Returns this JSON value as a |
|
open fun asInt(): Int
Returns this JSON value as an |
|
open fun asLong(): Long
Returns this JSON value as a |
|
open fun asObject(): JsonObject
Returns this JSON value as JsonObject, assuming that this value represents a JSON object. If this is not the case, an exception is thrown. |
|
open fun asString(): String
Returns this JSON value as String, assuming that this value represents a JSON string. If this is not the case, an exception is thrown. |
|
open fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one according to the contract specified in Object.equals. |
|
open fun toString(): String
Returns the JSON string for this value in its minimal form, without any additional whitespace. The result is guaranteed to be a valid input for the method Json.parse and to create a value that is equal to this object. fun toString(config: WriterConfig): String
Returns the JSON string for this value using the given formatting. |
|
fun writeTo(writer: Writer?, config: WriterConfig? = WriterConfig.MINIMAL): Unit
Writes the JSON representation of this value to the given writer using the given formatting. |
val
Represents the JSON literal |
|
val
Represents the JSON literal |
|
val
Represents the JSON literal |
fun
Reads a JSON value from the given string. |
|
fun
Reads a JSON value from the given reader. |
|
fun
Returns a JsonValue instance that represents the given fun
Returns a JsonValue instance that represents the given fun
Returns a JsonValue instance that represents the given fun
Returns a JsonValue instance that represents the given fun
Returns a JsonValue instance that represents the given string. fun
Returns a JsonValue instance that represents the given |
class JsonArray : JsonValue, MutableIterable<JsonValue>
Represents a JSON array, an ordered collection of JSON values. |
|
class JsonObject : JsonValue, Iterable<Member>
Represents a JSON object, a set of name/value pairs, where the names are strings and the values are JSON values. |