Class JSONArray

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
org.jose4j.json.internal.json_simple.JSONArray
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess, JSONAware, JSONStreamAware

public class JSONArray extends ArrayList implements JSONAware, JSONStreamAware
A JSON array. JSONObject supports java.util.List interface.
Author:
(originally) FangYidong [email protected]
See Also:
  • Constructor Details

    • JSONArray

      public JSONArray()
      Constructs an empty JSONArray.
    • JSONArray

      public JSONArray(Collection c)
      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

      public static void writeJSONString(Collection collection, Writer out) 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:
      collection - Collection
      out - Writer
      Throws:
      IOException - IOException
      See Also:
    • writeJSONString

      public void writeJSONString(Writer out) throws IOException
      Description copied from interface: JSONStreamAware
      write JSON string to out.
      Specified by:
      writeJSONString in interface JSONStreamAware
      Parameters:
      out - Writer
      Throws:
      IOException - IOException
    • toJSONString

      public static String toJSONString(Collection collection)
      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 - Collection
      Returns:
      JSON text, or "null" if list is null.
      See Also:
    • writeJSONString

      public static void writeJSONString(byte[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(byte[] array)
    • writeJSONString

      public static void writeJSONString(short[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(short[] array)
    • writeJSONString

      public static void writeJSONString(int[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(int[] array)
    • writeJSONString

      public static void writeJSONString(long[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(long[] array)
    • writeJSONString

      public static void writeJSONString(float[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(float[] array)
    • writeJSONString

      public static void writeJSONString(double[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(double[] array)
    • writeJSONString

      public static void writeJSONString(boolean[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(boolean[] array)
    • writeJSONString

      public static void writeJSONString(char[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(char[] array)
    • writeJSONString

      public static void writeJSONString(Object[] array, Writer out) throws IOException
      Throws:
      IOException
    • toJSONString

      public static String toJSONString(Object[] array)
    • toJSONString

      public String toJSONString()
      Specified by:
      toJSONString in interface JSONAware
      Returns:
      JSON text
    • toString

      public String toString()
      Returns a string representation of this array. This is equivalent to calling toJSONString().
      Overrides:
      toString in class AbstractCollection