Package net.minidev.json
Class JSONArray
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Object>
,Collection<Object>
,List<Object>
,RandomAccess
,SequencedCollection<Object>
,JSONAware
,JSONAwareEx
,JSONStreamAware
,JSONStreamAwareEx
public class JSONArray
extends ArrayList<Object>
implements List<Object>, JSONAwareEx, JSONStreamAwareEx
A JSON array. JSONObject supports java.util.List interface.
- Author:
- FangYidong <[email protected]>, Uriel Chemouni <[email protected]>
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendElement
(Object element) Appends the specified element and returns this.void
Explicitly Serialize Object as JSon Stringstatic String
toJSONString
(List<? extends Object> list) static String
toJSONString
(List<? extends Object> list, JSONStyle compression) Convert a list to JSON text.toJSONString
(JSONStyle compression) toString()
Override native toString()JSONAwareEx interfacevoid
write JSON string to out.void
writeJSONString
(Appendable out, JSONStyle compression) write JSON string to out.static void
writeJSONString
(Iterable<? extends Object> list, Appendable out, JSONStyle compression) Encode a list into JSON text and write it to out.static void
writeJSONString
(List<? extends Object> list, Appendable out) Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
JSONArray
public JSONArray() -
JSONArray
public JSONArray(int initialCapacity)
-
-
Method Details
-
toJSONString
-
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:
list
-compression
- Indicate compression level- Returns:
- JSON text, or "null" if list is null.
- See Also:
-
writeJSONString
public static void writeJSONString(Iterable<? extends Object> list, Appendable out, JSONStyle compression) throws IOException 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:
list
-out
-- Throws:
IOException
- See Also:
-
writeJSONString
- Throws:
IOException
-
appendElement
Appends the specified element and returns this. Handy alternative to add(E e) method.- Parameters:
element
- element to be appended to this array.- Returns:
- this
-
merge
-
toJSONString
Explicitly Serialize Object as JSon String- Specified by:
toJSONString
in interfaceJSONAware
- Returns:
- JSON text
-
toJSONString
- Specified by:
toJSONString
in interfaceJSONAwareEx
- Returns:
- JSON text
-
toString
Override native toString()- Overrides:
toString
in classAbstractCollection<Object>
-
toString
JSONAwareEx interface- Parameters:
compression
- compression param
-
writeJSONString
Description copied from interface:JSONStreamAware
write JSON string to out.- Specified by:
writeJSONString
in interfaceJSONStreamAware
- Throws:
IOException
-
writeJSONString
Description copied from interface:JSONStreamAwareEx
write JSON string to out.- Specified by:
writeJSONString
in interfaceJSONStreamAwareEx
- Throws:
IOException
-