Package com.ibm.json.java
Class JSONArray
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- com.ibm.json.java.JSONArray
-
- All Implemented Interfaces:
JSONArtifact,java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.List,java.util.RandomAccess
public class JSONArray extends java.util.ArrayList implements JSONArtifact
Extension of ArrayList that only allows values which are JSON-able. See JSONObject for a list of valid values. Instances of this class are not thread-safe.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)booleanadd(java.lang.Object element)booleanaddAll(int index, java.util.Collection collection)booleanaddAll(java.util.Collection collection)static JSONArrayparse(java.io.InputStream is)Convert a stream of JSONArray text into JSONArray form.static JSONArrayparse(java.io.Reader reader)Convert a stream (in reader form) of JSONArray text into object form.static JSONArrayparse(java.lang.String str)Convert a String of JSONArray text into object form.java.lang.Stringserialize()Convert this object into a String of JSON text.java.lang.Stringserialize(boolean verbose)Convert this object into a String of JSON text, specifying verbosity.voidserialize(java.io.OutputStream os)Convert this object into a stream of JSON text.voidserialize(java.io.OutputStream os, boolean verbose)Convert this object into a stream of JSON text.voidserialize(java.io.Writer writer)Convert this object into a stream of JSON text.voidserialize(java.io.Writer writer, boolean verbose)Convert this object into a stream of JSON text, specifying verbosity.java.lang.Objectset(int index, java.lang.Object element)-
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Method Detail
-
add
public void add(int index, java.lang.Object element)- Specified by:
addin interfacejava.util.List- Overrides:
addin classjava.util.ArrayList
-
add
public boolean add(java.lang.Object element)
- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.List- Overrides:
addin classjava.util.ArrayList
-
addAll
public boolean addAll(java.util.Collection collection)
- Specified by:
addAllin interfacejava.util.Collection- Specified by:
addAllin interfacejava.util.List- Overrides:
addAllin classjava.util.ArrayList
-
addAll
public boolean addAll(int index, java.util.Collection collection)- Specified by:
addAllin interfacejava.util.List- Overrides:
addAllin classjava.util.ArrayList
-
set
public java.lang.Object set(int index, java.lang.Object element)- Specified by:
setin interfacejava.util.List- Overrides:
setin classjava.util.ArrayList
-
parse
public static JSONArray parse(java.io.InputStream is) throws java.io.IOException
Convert a stream of JSONArray text into JSONArray form.- Parameters:
is- The inputStream from which to read the JSON. It will assume the input stream is in UTF-8 and read it as such.- Returns:
- The contructed JSONArray Object.
- Throws:
IOEXception- Thrown if an underlying IO error from the stream occurs, or if malformed JSON is read,java.io.IOException
-
parse
public static JSONArray parse(java.io.Reader reader) throws java.io.IOException
Convert a stream (in reader form) of JSONArray text into object form.- Parameters:
reader- The reader from which the JSONArray data is read.- Returns:
- The contructed JSONArray Object.
- Throws:
IOEXception- Thrown if an underlying IO error from the reader occurs, or if malformed JSON is read,java.io.IOException
-
parse
public static JSONArray parse(java.lang.String str) throws java.io.IOException
Convert a String of JSONArray text into object form.- Parameters:
str- The JSONArray string to parse into a Java Object.- Returns:
- The contructed JSONArray Object.
- Throws:
IOEXception- Thrown if malformed JSON is read,java.io.IOException
-
serialize
public void serialize(java.io.OutputStream os) throws java.io.IOExceptionConvert this object into a stream of JSON text. Same as calling serialize(os,false);- Specified by:
serializein interfaceJSONArtifact- Parameters:
os- The output stream to serialize data to.- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
serialize
public void serialize(java.io.OutputStream os, boolean verbose) throws java.io.IOExceptionConvert this object into a stream of JSON text. Same as calling serialize(writer,false);- Specified by:
serializein interfaceJSONArtifact- Parameters:
os- The output stream to serialize data to.verbose- Whether or not to write the JSON text in a verbose format.- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
serialize
public void serialize(java.io.Writer writer) throws java.io.IOExceptionConvert this object into a stream of JSON text. Same as calling serialize(writer,false);- Specified by:
serializein interfaceJSONArtifact- Parameters:
writer- The writer which to serialize the JSON text to.- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
serialize
public void serialize(java.io.Writer writer, boolean verbose) throws java.io.IOExceptionConvert this object into a stream of JSON text, specifying verbosity.- Specified by:
serializein interfaceJSONArtifact- Parameters:
writer- The writer which to serialize the JSON text to.- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
serialize
public java.lang.String serialize(boolean verbose) throws java.io.IOExceptionConvert this object into a String of JSON text, specifying verbosity.- Specified by:
serializein interfaceJSONArtifact- Parameters:
verbose- Whether or not to serialize in compressed for formatted Strings.- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
serialize
public java.lang.String serialize() throws java.io.IOExceptionConvert this object into a String of JSON text. Same as serialize(false);- Specified by:
serializein interfaceJSONArtifact- Throws:
java.io.IOException- Thrown on IO errors during serialization.
-
-