Class JsonArray

java.lang.Object
com.eclipsesource.json.JsonValue
com.eclipsesource.json.JsonArray
All Implemented Interfaces:
Serializable, Iterable<JsonValue>

public class JsonArray extends JsonValue implements Iterable<JsonValue>
Represents a JSON array, an ordered collection of JSON values.

Elements can be added using the add(...) methods which accept instances of JsonValue, strings, primitive numbers, and boolean values. To replace an element of an array, use the set(int, ...) methods.

Elements can be accessed by their index using get(int). This class also supports iterating over the elements in document order using an iterator() or an enhanced for loop:

 for (JsonValue value : jsonArray) {
   ...
 }
 

An equivalent List can be obtained from the method values().

Note that this class is not thread-safe. If multiple threads access a JsonArray instance concurrently, while at least one of these threads modifies the contents of this array, access to the instance must be synchronized externally. Failure to do so may lead to an inconsistent state.

This class is not supposed to be extended by clients.

See Also: