Class JsonArray

java.lang.Object
jodd.json.JsonArray
All Implemented Interfaces:
Iterable<Object>

public class JsonArray extends Object implements Iterable<Object>
Representation of JSON array.
See Also:
  • Field Details

  • Constructor Details

    • JsonArray

      public JsonArray()
      Creates an empty instance.
    • JsonArray

      public JsonArray(List list)
      Creates an instance from a List. The List is not copied.
  • Method Details

    • getString

      public String getString(int pos)
      Returns the string at position pos in the array.
    • getInteger

      public Integer getInteger(int pos)
      Returns the integer at position pos in the array.
    • getLong

      public Long getLong(int pos)
      Returns the long at position pos in the array.
    • getDouble

      public Double getDouble(int pos)
      Returns the double at position pos in the array.
    • getFloat

      public Float getFloat(int pos)
      Returns the Float at position pos in the array.
    • getBoolean

      public Boolean getBoolean(int pos)
      Returns the boolean at position pos in the array.
    • getJsonObject

      public JsonObject getJsonObject(int pos)
      Returns the JsonObject at position pos in the array.
    • getJsonArray

      public JsonArray getJsonArray(int pos)
      Returns the JsonArray at position pos in the array.
    • getBinary

      public byte[] getBinary(int pos)
      Returns the byte[] at position pos in the array.

      JSON itself has no notion of a binary, so this method assumes there is a String value and it contains a Base64 encoded binary, which it decodes if found and returns.

    • getValue

      public Object getValue(int pos)
      Returns the object value at position pos in the array.
    • hasNull

      public boolean hasNull(int pos)
      Returns true if there is a null value at given index.
    • add

      public JsonArray add(Enum value)
      Adds an enum to the JSON array.

      JSON has no concept of encoding Enums, so the Enum will be converted to a String using the Enum.name method and the value added as a String.

    • add

      public JsonArray add(CharSequence value)
      Adds a CharSequence to the JSON array.
    • add

      public JsonArray add(String value)
      Adds a string to the JSON array.
    • add

      public JsonArray add(Integer value)
      Adds an integer to the JSON array.
    • add

      public JsonArray add(Long value)
      Adds a long to the JSON array.
    • add

      public JsonArray add(Double value)
      Adds a double to the JSON array.
    • add

      public JsonArray add(Float value)
      Adds a float to the JSON array.
    • add

      public JsonArray add(Boolean value)
      Adds a boolean to the JSON array.
    • addNull

      public JsonArray addNull()
      Adds a null value to the JSON array.
    • add

      public JsonArray add(JsonObject value)
      Adds a JSON object to the JSON array.
    • add

      public JsonArray add(JsonArray value)
      Adds another JSON array to the JSON array.
    • add

      public JsonArray add(byte[] value)
      Adds a binary value to the JSON array.

      JSON has no notion of binary so the binary will be base64 encoded to a String, and the String added.

    • add

      public JsonArray add(Object value)
      Adds an object to the JSON array.
    • addAll

      public JsonArray addAll(JsonArray array)
      Appends all of the elements in the specified array to the end of this JSON array.
    • contains

      public boolean contains(Object value)
      Returns true if given value exist.
    • remove

      public boolean remove(Object value)
      Removes the specified value from the JSON array.
    • remove

      public Object remove(int pos)
      Removes the value at the specified position in the JSON array.
    • size

      public int size()
      Returns the number of values in this JSON array.
    • isEmpty

      public boolean isEmpty()
      Returns true if JSON array is empty.
    • list

      public List<Object> list()
      Returns the underlying list.
    • clear

      public JsonArray clear()
      Removes all entries from the JSON array.
    • iterator

      public Iterator<Object> iterator()
      Returns an iterator over the values in the JSON array.
      Specified by:
      iterator in interface Iterable<Object>
    • stream

      public Stream<Object> stream()
      Returns a Stream over the entries in the JSON array
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      static boolean arrayEquals(List<?> l1, Object o2)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object