com.ibm.json.java

Class JSONArray

  1. java.lang.Object
  2. extended byjava.util.AbstractCollection<E>
  3. extended byjava.util.AbstractList<E>
  4. extended byjava.util.ArrayList
  5. extended bycom.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

  1. public class JSONArray
  2. extends java.util.ArrayList
  3. 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

Field Summary

Fields inherited from class java.util.AbstractList
modCount

Constructor Summary

Constructor and Description
JSONArray()
Create a new instance of this class.
JSONArray(int initialCapacity)
Create a new instance of this class with the specified initial capacity.

Method Summary

Modifier and Type Method and Description
  1. void
add(int index,java.lang.Object element)
  1. boolean
add(java.lang.Object element)
  1. boolean
addAll(java.util.Collection collection)
  1. boolean
addAll(int index,java.util.Collection collection)
  1. static
  2. JSONArray
parse(java.io.InputStream is)
Convert a stream of JSONArray text into JSONArray form.
  1. static
  2. JSONArray
parse(java.io.Reader reader)
Convert a stream (in reader form) of JSONArray text into object form.
  1. static
  2. JSONArray
parse(java.lang.String str)
Convert a String of JSONArray text into object form.
  1. java.lang.String
serialize()
Convert this object into a String of JSON text.
  1. java.lang.String
serialize(boolean verbose)
Convert this object into a String of JSON text, specifying verbosity.
  1. void
serialize(java.io.OutputStream os)
Convert this object into a stream of JSON text.
  1. void
serialize(java.io.OutputStream os,boolean verbose)
Convert this object into a stream of JSON text.
  1. void
serialize(java.io.Writer writer)
Convert this object into a stream of JSON text.
  1. void
serialize(java.io.Writer writer,boolean verbose)
Convert this object into a stream of JSON text, specifying verbosity.
  1. java.lang.Object
set(int index,java.lang.Object element)
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, size, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractList
equals, hashCode
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.List
containsAll, equals, hashCode

Constructor Detail

JSONArray

  1. public JSONArray()
Create a new instance of this class.

JSONArray

  1. public JSONArray(int initialCapacity)
Create a new instance of this class with the specified initial capacity.

Method Detail

add

  1. public void add(int index,
  2. java.lang.Object element)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

add

  1. public boolean add(java.lang.Object element)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

addAll

  1. public boolean addAll(java.util.Collection collection)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

addAll

  1. public boolean addAll(int index,
  2. java.util.Collection collection)
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

set

  1. public java.lang.Object set(int index,
  2. java.lang.Object element)
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.ArrayList

parse

  1. public static JSONArray parse(java.io.InputStream is)
  2. 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

  1. public static JSONArray parse(java.io.Reader reader)
  2. 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

  1. public static JSONArray parse(java.lang.String str)
  2. 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

  1. public void serialize(java.io.OutputStream os)
  2. throws java.io.IOException
Convert this object into a stream of JSON text. Same as calling serialize(os,false);
Specified by:
serialize in interface JSONArtifact
Parameters:
os - The output stream to serialize data to.
Throws:
java.io.IOException - Thrown on IO errors during serialization.

serialize

  1. public void serialize(java.io.OutputStream os,
  2. boolean verbose)
  3. throws java.io.IOException
Convert this object into a stream of JSON text. Same as calling serialize(writer,false);
Specified by:
serialize in interface JSONArtifact
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

  1. public void serialize(java.io.Writer writer)
  2. throws java.io.IOException
Convert this object into a stream of JSON text. Same as calling serialize(writer,false);
Specified by:
serialize in interface JSONArtifact
Parameters:
writer - The writer which to serialize the JSON text to.
Throws:
java.io.IOException - Thrown on IO errors during serialization.

serialize

  1. public void serialize(java.io.Writer writer,
  2. boolean verbose)
  3. throws java.io.IOException
Convert this object into a stream of JSON text, specifying verbosity.
Specified by:
serialize in interface JSONArtifact
Parameters:
writer - The writer which to serialize the JSON text to.
Throws:
java.io.IOException - Thrown on IO errors during serialization.

serialize

  1. public java.lang.String serialize( boolean verbose)
  2. throws java.io.IOException
Convert this object into a String of JSON text, specifying verbosity.
Specified by:
serialize in interface JSONArtifact
Parameters:
verbose - Whether or not to serialize in compressed for formatted Strings.
Throws:
java.io.IOException - Thrown on IO errors during serialization.

serialize

  1. public java.lang.String serialize( )
  2. throws java.io.IOException
Convert this object into a String of JSON text. Same as serialize(false);
Specified by:
serialize in interface JSONArtifact
Throws:
java.io.IOException - Thrown on IO errors during serialization.