java.lang.Object
io.helidon.json.JsonValue
- Direct Known Subclasses:
JsonArray,JsonBoolean,JsonNull,JsonNumber,JsonObject,JsonString
public abstract sealed class JsonValue
extends Object
permits JsonArray, JsonBoolean, JsonNull, JsonNumber, JsonObject, JsonString (not exhaustive)
Base class for all JSON value types in Helidon JSON processing.
This module is incubating. These APIs may change in any version of Helidon, including backward incompatible changes.
-
Method Summary
Modifier and TypeMethodDescriptionasArray()Cast this value to a JsonArray if it is of array type.Cast this value to a JsonBoolean if it is of boolean type.asNumber()Cast this value to a JsonNumber if it is of number type.asObject()Cast this value to a JsonObject if it is of object type.asString()Cast this value to a JsonString if it is of string type.static JsonObject.BuilderA new fluent API builder to construct anJsonObject.abstract voidtoJson(JsonGenerator generator) Write this JSON value to the provided generator.toString()abstract JsonValueTypetype()Return the type of this JSON value.
-
Method Details
-
objectBuilder
A new fluent API builder to construct anJsonObject.- Returns:
- a new builder
-
type
Return the type of this JSON value.- Returns:
- the JsonValueType of this value
-
toJson
Write this JSON value to the provided generator.- Parameters:
generator- the generator to write to
-
toString
-
asString
Cast this value to a JsonString if it is of string type.- Returns:
- this value as a JsonString
- Throws:
JsonException- if this value is not a string
-
asNumber
Cast this value to a JsonNumber if it is of number type.- Returns:
- this value as a JsonNumber
- Throws:
JsonException- if this value is not a number
-
asObject
Cast this value to a JsonObject if it is of object type.- Returns:
- this value as a JsonObject
- Throws:
JsonException- if this value is not an object
-
asArray
Cast this value to a JsonArray if it is of array type.- Returns:
- this value as a JsonArray
- Throws:
JsonException- if this value is not an array
-
asBoolean
Cast this value to a JsonBoolean if it is of boolean type.- Returns:
- this value as a JsonBoolean
- Throws:
JsonException- if this value is not a boolean
-