Class JSONArray
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
com.pnfsoftware.jeb.util.encoding.json.JSONArray
- All Implemented Interfaces:
JSONAware,JSONStreamAware,Serializable,Cloneable,Iterable,Collection,List,RandomAccess
A JSON array. JSONObject supports java.util.List interface.
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty JSONArray.Constructs a JSONArray containing the elements of the specified collection, in the order they are returned by the collection's iterator. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringtoJSONString(boolean[] array) static StringtoJSONString(byte[] array) static StringtoJSONString(char[] array) static StringtoJSONString(double[] array) static StringtoJSONString(float[] array) static StringtoJSONString(int[] array) static StringtoJSONString(long[] array) static StringtoJSONString(short[] array) static StringtoJSONString(Object[] array) static StringtoJSONString(Collection collection) Convert a list to JSON text.toString()Returns a string representation of this array.static voidwriteJSONString(boolean[] array, Writer out) static voidwriteJSONString(byte[] array, Writer out) static voidwriteJSONString(char[] array, Writer out) static voidwriteJSONString(double[] array, Writer out) static voidwriteJSONString(float[] array, Writer out) static voidwriteJSONString(int[] array, Writer out) static voidwriteJSONString(long[] array, Writer out) static voidwriteJSONString(short[] array, Writer out) voidwriteJSONString(Writer out) write JSON string to out.static voidwriteJSONString(Object[] array, Writer out) static voidwriteJSONString(Collection collection, Writer out) Encode a list into JSON text and write it to out.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
JSONArray
public JSONArray()Constructs an empty JSONArray. -
JSONArray
Constructs a JSONArray containing the elements of the specified collection, in the order they are returned by the collection's iterator.- Parameters:
c- the collection whose elements are to be placed into this JSONArray
-
-
Method Details
-
writeJSONString
Encode a list into JSON text and write it to out. If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level.- Parameters:
collection-out-- Throws:
IOException- See Also:
-
JSONValue.writeJSONString(Object, Writer)
-
writeJSONString
Description copied from interface:JSONStreamAwarewrite JSON string to out.- Specified by:
writeJSONStringin interfaceJSONStreamAware- Throws:
IOException
-
toJSONString
Convert a list to JSON text. The result is a JSON array. If this list is also a JSONAware, JSONAware specific behaviours will be omitted at this top level.- Parameters:
collection-- Returns:
- JSON text, or "null" if list is null.
- See Also:
-
JSONValue.toJSONString(Object)
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
writeJSONString
- Throws:
IOException
-
toJSONString
-
toJSONString
- Specified by:
toJSONStringin interfaceJSONAware- Returns:
- JSON text
-
toString
Returns a string representation of this array. This is equivalent to callingtoJSONString().- Overrides:
toStringin classAbstractCollection
-