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 JsonArray
add(byte[] value)
Adds a binary value to the JSON array.JsonArray
add(java.lang.Boolean value)
Adds a boolean to the JSON array.JsonArray
add(java.lang.CharSequence value)
Adds aCharSequence
to the JSON array.JsonArray
add(java.lang.Double value)
Adds a double to the JSON array.JsonArray
add(java.lang.Enum value)
Adds an enum to the JSON array.JsonArray
add(java.lang.Float value)
Adds a float to the JSON array.JsonArray
add(java.lang.Integer value)
Adds an integer to the JSON array.JsonArray
add(java.lang.Long value)
Adds a long to the JSON array.JsonArray
add(java.lang.Object value)
Adds an object to the JSON array.JsonArray
add(java.lang.String value)
Adds a string to the JSON array.JsonArray
add(JsonArray value)
Adds another JSON array to the JSON array.JsonArray
add(JsonObject value)
Adds a JSON object to the JSON array.JsonArray
addAll(JsonArray array)
Appends all of the elements in the specified array to the end of this JSON array.JsonArray
addNull()
Adds anull
value to the JSON array.JsonArray
clear()
Removes all entries from the JSON array.boolean
contains(java.lang.Object value)
Returnstrue
if given value exist.boolean
equals(java.lang.Object o)
byte[]
getBinary(int pos)
Returns the byte[] at positionpos
in the array.java.lang.Boolean
getBoolean(int pos)
Returns the boolean at positionpos
in the array.java.lang.Double
getDouble(int pos)
Returns the double at positionpos
in the array.java.lang.Float
getFloat(int pos)
Returns the Float at positionpos
in the array.java.lang.Integer
getInteger(int pos)
Returns the integer at positionpos
in the array.JsonArray
getJsonArray(int pos)
Returns the JsonArray at positionpos
in the array.JsonObject
getJsonObject(int pos)
Returns the JsonObject at positionpos
in the array.java.lang.Long
getLong(int pos)
Returns the long at positionpos
in the array.java.lang.String
getString(int pos)
Returns the string at positionpos
in the array.java.lang.Object
getValue(int pos)
Returns the object value at positionpos
in the array.int
hashCode()
boolean
hasNull(int pos)
Returnstrue
if there is anull
value at given index.boolean
isEmpty()
Returnstrue
if 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.Object
remove(int pos)
Removes the value at the specified position in the JSON array.boolean
remove(java.lang.Object value)
Removes the specified value from the JSON array.int
size()
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.String
toString()
-
-
-
Method Detail
-
getString
public java.lang.String getString(int pos)
Returns the string at positionpos
in the array.
-
getInteger
public java.lang.Integer getInteger(int pos)
Returns the integer at positionpos
in the array.
-
getLong
public java.lang.Long getLong(int pos)
Returns the long at positionpos
in the array.
-
getDouble
public java.lang.Double getDouble(int pos)
Returns the double at positionpos
in the array.
-
getFloat
public java.lang.Float getFloat(int pos)
Returns the Float at positionpos
in the array.
-
getBoolean
public java.lang.Boolean getBoolean(int pos)
Returns the boolean at positionpos
in the array.
-
getJsonObject
public JsonObject getJsonObject(int pos)
Returns the JsonObject at positionpos
in the array.
-
getJsonArray
public JsonArray getJsonArray(int pos)
Returns the JsonArray at positionpos
in the array.
-
getBinary
public byte[] getBinary(int pos)
Returns the byte[] at positionpos
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 java.lang.Object getValue(int pos)
Returns the object value at positionpos
in the array.
-
hasNull
public boolean hasNull(int pos)
Returnstrue
if there is anull
value 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.name
method and the value added as a String.
-
add
public JsonArray add(java.lang.CharSequence value)
Adds aCharSequence
to 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 anull
value 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)
Returnstrue
if 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()
Returnstrue
if 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:
iterator
in 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:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-