Package rife.json

Class JsonArray

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess

public class JsonArray extends ArrayList<Object>
A JsonArray represents a JSON array as a regular list, with additional fluent construction methods and typed value retrieval.

The values that are stored are plain Java instances: String, Long, Double, Boolean, null, JsonObject and JsonArray.

All the mutation methods convert maps, collections and arrays to JsonObject and JsonArray instances, while values that are assigned through sublist views bypass this conversion.

The typed retrieval methods are lenient. Strings will be parsed into the requested numeric or boolean types and numbers will be truncated when narrower types are requested. Elements that are null return zero-like values.

Since:
1.10
See Also:
  • Constructor Details

    • JsonArray

      public JsonArray()
      Creates an empty JSON array.

      Elements can afterwards be added with the regular list methods or with the fluent construction methods.

      Since:
      1.10
      See Also:
    • JsonArray

      public JsonArray(Collection<?> elements)
      Creates a JSON array with the elements of a collection.

      This constructor will copy over the elements of the provided collection in the collection's iteration order, while nested maps, collections and arrays are converted to JsonObject and JsonArray instances.

      Parameters:
      elements - the collection whose elements become the elements of this JSON array, in the collection's iteration order
      Since:
      1.10
      See Also:
  • Method Details