Package jodd.json
Class JsonArray
- java.lang.Object
-
- jodd.json.JsonArray
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>
public class JsonArray extends java.lang.Object implements java.lang.Iterable<java.lang.Object>Representation of JSON array.- See Also:
JsonObject
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArrayadd(byte[] value)Adds a binary value to the JSON array.JsonArrayadd(java.lang.Boolean value)Adds a boolean to the JSON array.JsonArrayadd(java.lang.CharSequence value)Adds aCharSequenceto the JSON array.JsonArrayadd(java.lang.Double value)Adds a double to the JSON array.JsonArrayadd(java.lang.Enum value)Adds an enum to the JSON array.JsonArrayadd(java.lang.Float value)Adds a float to the JSON array.JsonArrayadd(java.lang.Integer value)Adds an integer to the JSON array.JsonArrayadd(java.lang.Long value)Adds a long to the JSON array.JsonArrayadd(java.lang.Object value)Adds an object to the JSON array.JsonArrayadd(java.lang.String value)Adds a string to the JSON array.JsonArrayadd(JsonArray value)Adds another JSON array to the JSON array.JsonArrayadd(JsonObject value)Adds a JSON object to the JSON array.JsonArrayaddAll(JsonArray array)Appends all of the elements in the specified array to the end of this JSON array.JsonArrayaddNull()Adds anullvalue to the JSON array.JsonArrayclear()Removes all entries from the JSON array.booleancontains(java.lang.Object value)Returnstrueif given value exist.booleanequals(java.lang.Object o)byte[]getBinary(int pos)Returns the byte[] at positionposin the array.java.lang.BooleangetBoolean(int pos)Returns the boolean at positionposin the array.java.lang.DoublegetDouble(int pos)Returns the double at positionposin the array.java.lang.FloatgetFloat(int pos)Returns the Float at positionposin the array.java.lang.IntegergetInteger(int pos)Returns the integer at positionposin the array.JsonArraygetJsonArray(int pos)Returns the JsonArray at positionposin the array.JsonObjectgetJsonObject(int pos)Returns the JsonObject at positionposin the array.java.lang.LonggetLong(int pos)Returns the long at positionposin the array.java.lang.StringgetString(int pos)Returns the string at positionposin the array.java.lang.ObjectgetValue(int pos)Returns the object value at positionposin the array.inthashCode()booleanhasNull(int pos)Returnstrueif there is anullvalue at given index.booleanisEmpty()Returnstrueif JSON array is empty.java.util.Iterator<java.lang.Object>iterator()Returns an iterator over the values in the JSON array.java.util.List<java.lang.Object>list()Returns the underlying list.java.lang.Objectremove(int pos)Removes the value at the specified position in the JSON array.booleanremove(java.lang.Object value)Removes the specified value from the JSON array.intsize()Returns the number of values in this JSON array.java.util.stream.Stream<java.lang.Object>stream()Returns a Stream over the entries in the JSON arrayjava.lang.StringtoString()
-
-
-
Method Detail
-
getString
public java.lang.String getString(int pos)
Returns the string at positionposin the array.
-
getInteger
public java.lang.Integer getInteger(int pos)
Returns the integer at positionposin the array.
-
getLong
public java.lang.Long getLong(int pos)
Returns the long at positionposin the array.
-
getDouble
public java.lang.Double getDouble(int pos)
Returns the double at positionposin the array.
-
getFloat
public java.lang.Float getFloat(int pos)
Returns the Float at positionposin the array.
-
getBoolean
public java.lang.Boolean getBoolean(int pos)
Returns the boolean at positionposin the array.
-
getJsonObject
public JsonObject getJsonObject(int pos)
Returns the JsonObject at positionposin the array.
-
getJsonArray
public JsonArray getJsonArray(int pos)
Returns the JsonArray at positionposin the array.
-
getBinary
public byte[] getBinary(int pos)
Returns the byte[] at positionposin 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 java.lang.Object getValue(int pos)
Returns the object value at positionposin the array.
-
hasNull
public boolean hasNull(int pos)
Returnstrueif there is anullvalue at given index.
-
add
public JsonArray add(java.lang.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.namemethod and the value added as a String.
-
add
public JsonArray add(java.lang.CharSequence value)
Adds aCharSequenceto the JSON array.
-
add
public JsonArray add(java.lang.String value)
Adds a string to the JSON array.
-
add
public JsonArray add(java.lang.Integer value)
Adds an integer to the JSON array.
-
add
public JsonArray add(java.lang.Long value)
Adds a long to the JSON array.
-
add
public JsonArray add(java.lang.Double value)
Adds a double to the JSON array.
-
add
public JsonArray add(java.lang.Float value)
Adds a float to the JSON array.
-
add
public JsonArray add(java.lang.Boolean value)
Adds a boolean to the JSON array.
-
addNull
public JsonArray addNull()
Adds anullvalue to the JSON array.
-
add
public JsonArray add(JsonObject value)
Adds a JSON object 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(java.lang.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(java.lang.Object value)
Returnstrueif given value exist.
-
remove
public boolean remove(java.lang.Object value)
Removes the specified value from the JSON array.
-
remove
public java.lang.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()
Returnstrueif JSON array is empty.
-
list
public java.util.List<java.lang.Object> list()
Returns the underlying list.
-
clear
public JsonArray clear()
Removes all entries from the JSON array.
-
iterator
public java.util.Iterator<java.lang.Object> iterator()
Returns an iterator over the values in the JSON array.- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Object>
-
stream
public java.util.stream.Stream<java.lang.Object> stream()
Returns a Stream over the entries in the JSON array
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-