Interface JSONValue

All Superinterfaces:
Formattable
All Known Subinterfaces:
JSONArray, JSONNumber, JSONObject, JSONString
All Known Implementing Classes:
JSONArrayImpl, JSONLiteral, JSONNumberImpl, JSONObjectImpl, JSONStringImpl

@ClassVersion(sourceVersion="$Id: JSONValue.java 1258 2026-06-04 18:33:06Z tquadrat $") @API(status=STABLE, since="0.25.0") public sealed interface JSONValue extends Formattable permits JSONArray, JSONLiteral, JSONNumber, JSONObject, JSONString

This interface describes the base for all the JSON datatypes.

JSONValue implements Formattable for the implementation of pretty-printed output through String.format( "%s", value ) or similar.

formatTo(Formatter,int,int,int) ignores the arguments flags and precision, while the width argument is used internally. Therefore, a call like String.format( "%10s", value ) may result in some unexpected output.

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: JSONValue.java 1258 2026-06-04 18:33:06Z tquadrat $
Since:
0.25.0
UML Diagram
UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONValue"

UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONValue"

UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONValue"
  • Method Summary

    Modifier and Type
    Method
    Description
    default JSONArray
    Returns this JSON value as JSONArray, assuming that this value represents a JSON array.
    default JSONLiteral
    Returns this JSON value as JSON literals false or true, assuming that this value represents a JSON Boolean.
    default JSONNumber
    Returns this JSON value as JSONNumber, assuming that this value represents a JSON number.
    default JSONObject
    Returns this JSON value as JSONObject, assuming that this value represents a JSON object.
    default JSONString
    Returns this JSON value as JSONString, assuming that this value represents a JSON String.
    void
    formatTo(Formatter formatter, int flags, int width, int precision)
    default boolean
    Detects whether this value represents a JSON array.
    default boolean
    Detects whether this value represents a boolean value.
    default boolean
    Detects whether this value represents the JSON literal false.
    default boolean
    Detects whether this value represents the JSON literal null.
    default boolean
    Detects whether this value represents a JSON number.
    default boolean
    Detects whether this value represents a JSON object.
    default boolean
    Detects whether this value represents a JSON string.
    default boolean
    Detects whether this value represents the JSON literal true.