Class JsonArray

java.lang.Object
io.helidon.json.JsonValue
io.helidon.json.JsonArray

public final class JsonArray extends JsonValue
Represents a JSON array value containing an ordered list of JSON values.

This module is incubating. These APIs may change in any version of Helidon, including backward incompatible changes.

  • Method Details

    • create

      public static JsonArray create(List<? extends JsonValue> jsonValues)
      Create a JsonArray from a list of JsonValue instances.
      Parameters:
      jsonValues - the list of JSON values
      Returns:
      a new JsonArray
    • create

      public static JsonArray create(JsonValue... jsonValues)
      Create a JsonArray from an array of JsonValue instances.
      Parameters:
      jsonValues - the array of JSON values
      Returns:
      a new JsonArray
    • createStrings

      public static JsonArray createStrings(List<String> values)
      Create a JsonArray from a list of strings.
      Parameters:
      values - the list of string values
      Returns:
      a new JsonArray containing JsonString values
    • createNumbers

      public static JsonArray createNumbers(List<BigDecimal> values)
      Create a JsonArray from a list of BigDecimal numbers.
      Parameters:
      values - the list of BigDecimal values
      Returns:
      a new JsonArray containing JsonNumber values
    • createBooleans

      public static JsonArray createBooleans(List<Boolean> values)
      Create a JsonArray from a list of booleans.
      Parameters:
      values - the list of boolean values
      Returns:
      a new JsonArray containing JsonBoolean values
    • empty

      public static JsonArray empty()
      Returns the shared empty JSON array instance.
      Returns:
      the empty JSON array
    • get

      public Optional<JsonValue> get(int index)
      Return the JsonValue at the specified index as an Optional.
      Parameters:
      index - the index of the element to return
      Returns:
      an Optional containing the element at the specified position, or empty if out of bounds
    • get

      public JsonValue get(int index, JsonValue defaultValue)
      Return the JsonValue at the specified index, or the default value if the index is out of bounds.
      Parameters:
      index - the index of the element to return
      defaultValue - the value to return if the index is out of bounds
      Returns:
      the element at the specified position, or the default value
    • values

      public List<JsonValue> values()
      Return an unmodifiable list of all values in this array.
      Returns:
      an unmodifiable list of JsonValue instances
    • type

      public JsonValueType type()
      Description copied from class: JsonValue
      Return the type of this JSON value.
      Specified by:
      type in class JsonValue
      Returns:
      the JsonValueType of this value
    • toJson

      public void toJson(JsonGenerator generator)
      Description copied from class: JsonValue
      Write this JSON value to the provided generator.
      Specified by:
      toJson in class JsonValue
      Parameters:
      generator - the generator to write to
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object