Package net.minidev.json
Class JSONArray
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Object>,Collection<Object>,List<Object>,RandomAccess,JSONAware,JSONAwareEx,JSONStreamAware,JSONStreamAwareEx
A JSON array. JSONObject supports java.util.List interface.
- Author:
- FangYidong <fangyidong@yahoo.com.cn>, Uriel Chemouni <uchemouni@gmail.com>
- 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. same effect that add(E e) method.voidMerges the specified object into this array. can trigger an add(E e) or addAll(E e) method.Explicitly Serialize Object as JSon Stringstatic StringtoJSONString(List<? extends Object> list) static StringtoJSONString(List<? extends Object> list, JSONStyle compression) Convert a list to JSON text.toJSONString(JSONStyle compression) Converts this object to JSON string representation with specified compression style.toString()Override native toString()JSONAwareEx interfacevoidJSONStreamAwareEx interfacevoidwriteJSONString(Appendable out, JSONStyle compression) JSONStreamAwareEx interfacestatic voidwriteJSONString(Iterable<? extends Object> list, Appendable out, JSONStyle compression) Encode a list into JSON text and write it to out.static voidwriteJSONString(List<? extends Object> list, Appendable 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() -
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
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
-
appendElement
Appends the specified element and returns this. same effect that add(E e) method.- Parameters:
element- element to be appended to this array.- Returns:
- this
-
merge
Merges the specified object into this array. can trigger an add(E e) or addAll(E e) method.- Parameters:
o2-
-
toJSONString
Explicitly Serialize Object as JSon String- Specified by:
toJSONStringin interfaceJSONAware- Returns:
- JSON text
-
toJSONString
Description copied from interface:JSONAwareExConverts this object to JSON string representation with specified compression style.- Specified by:
toJSONStringin interfaceJSONAwareEx- Parameters:
compression- the JSON style for formatting- Returns:
- JSON text
-
toString
Override native toString()- Overrides:
toStringin classAbstractCollection<Object>
-
toString
JSONAwareEx interface- Parameters:
compression- compression param
-
writeJSONString
JSONStreamAwareEx interface- Specified by:
writeJSONStringin interfaceJSONStreamAware- Parameters:
out- output stream- Throws:
IOException- if I/O error occurs
-
writeJSONString
JSONStreamAwareEx interface- Specified by:
writeJSONStringin interfaceJSONStreamAwareEx- Parameters:
out- output streamcompression- compression param- Throws:
IOException- if I/O error occurs
-