Read From Inputstream and Convert to Json Object in Java



org.apache.flash.json4j
Class JSONArray

coffee.lang.Object        extended by java.util.AbstractCollection<Due east>        extended by java.util.AbstractList<East>        extended by coffee.util.ArrayList        extended by         org.apache.flash.json4j.JSONArray      
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess, JSONArtifact

public course            JSONArray            
extends ArrayList
implements JSONArtifact

Extension of ArrayList that merely allows values which are JSON-able. Encounter JSONObject for a listing of valid values. Instances of this class are not thread-safety.

See Also:
Serialized Course

Field Summary
Fields inherited from grade java.util.AbstractList
modCount
Constructor Summary
JSONArray()
Create a new instance of this class.
JSONArray(Drove col)
Create a new case of this form based off the contents of the passed in collection
JSONArray(Collection col, boolean includeSuperclass)
Create a new example of this class based off the contents of the passed in collection
JSONArray(InputStream is)
Create a new instance of this grade from the data provided from the input stream.
JSONArray(InputStream is, boolean strict)
Create a new case of this course from the information provided from the input stream.
JSONArray(int initialCapacity)
Create a new example of this class with the specified initial capacity.
JSONArray(Object[] elems)
Create a new instance of this class based off the contents of the passed object array.
JSONArray(Object[] elems, boolean includeSuperclass)
Create a new case of this class based off the contents of the passed object array.
JSONArray(Reader rdr)
Create a new case of this course from the data provided from the reader.
JSONArray(Reader rdr, boolean strict)
Create a new case of this class from the information provided from the reader.
JSONArray(String str)
Create a new instance of this class from the provided JSON object string.
JSONArray(String str, boolean strict)
Create a new instance of this class from the provided JSON object cord.
Method Summary
 void add(int alphabetize, Object chemical element)
 boolean add(Object chemical element)
 boolean add(Object element, boolean includeSuperclass)
 boolean addAll(Collection collection)
 boolean addAll(int alphabetize, Collection collection)
 boolean getBoolean(int alphabetize)
Function to obtain a value at the specified index every bit a boolean.
 double getDouble(int index)
Function to obtain a value at the specified alphabetize as a double.
 Object getIndex(int index)
Function to go a JSONArray entry at a specified alphabetize.
 int getInt(int index)
Function to obtain a value at the specified index as an int.
 JSONArray getJSONArray(int alphabetize)
Utility method to obtain the specified index as a JSONArray Only values that are instances of JSONArray volition exist returned.
 JSONObject getJSONObject(int index)
Utility method to obtain the specified cardinal as a JSONObject Simply values that are instances of JSONObject will exist returned.
 long getLong(int index)
Function to obtain a value at the specified index as a long.
 short getShort(int index)
Function to obtain a value at the specified alphabetize equally a short.
 String getString(int index)
Role to obtain a value at the specified index every bit a string.
 boolean isNull(int alphabetize)
Utility function for testing if an element at index 'idx' is zero or not.
 String join(String str)
Method to mimic the behavior of the JavaScript array join function
 int length()
Utility part that maps ArrayList.size() to length, for compatibility to other JSON parsers.
 Object opt(int index)
Method to get the object at that position, or null if outside the array range.
 Object opt(int index, Object defaultValue)
Method to become the object at that position, or null if outside the array range.
 boolean optBoolean(int alphabetize)
Method to obtain the value at index every bit an boolean, or 'false' if outside the array.
 boolean optBoolean(int alphabetize, boolean defaultValue)
Method to obtain the value at index as an boolean, or 'defaultValue' if exterior the array.
 double optDouble(int index)
Method to obtain the value at index as a double, or Double.NaN if outside the assortment.
 double optDouble(int index, double defaultValue)
Method to obtain the value at index as a double, or Double.NaN if outside the array.
 int optInt(int index)
Method to obtain the value at index equally an int, or '0' if outside the array.
 int optInt(int index, int defaultValue)
Method to obtain the value at index as an int, or defaultValue if outside the array.
 long optLong(int alphabetize)
Method to obtain the value at alphabetize as a long, or '0' if exterior the array.
 long optLong(int index, long defaultValue)
Method to obtain the value at index as a long, or defaultValue if exterior the array.
 short optShort(int index)
Method to obtain the value at alphabetize every bit a short, or '0' if outside the array.
 short optShort(int index, short defaultValue)
Method to obtain the value at index as a short, or '0' if outside the array.
 String optString(int index)
Method to obtain the value at alphabetize as a String, or null if exterior the array.
 String optString(int index, String defaultValue)
Method to obtain the value at index as a String, or defaultValue if exterior the array.
 JSONArray put(boolean value)
Method to identify a int into the array.
 JSONArray put(Collection value)
Method to place a map into the array.
 JSONArray put(Drove value, boolean includeSuperclass)
Method to place a map into the array.
 JSONArray put(double value)
Method to place a double into the array.
 JSONArray put(int value)
Method to identify a int into the array.
 JSONArray put(int index, boolean value)
Method to place a boolean into the assortment.
 JSONArray put(int alphabetize, Collection value)
Method to identify a map into the array.
 JSONArray put(int alphabetize, Collection value, boolean includeSuperclass)
Method to place a map into the assortment.
 JSONArray put(int index, double value)
Method to place a double into the assortment.
 JSONArray put(int index, int value)
Method to place an int into the array.
 JSONArray put(int index, long value)
Method to place a long into the assortment.
 JSONArray put(int alphabetize, Map value)
Method to place a java.util.Map case in the array.
 JSONArray put(int index, Map value, boolean includeSuperclass)
Method to place a java.util.Map instance in the array.
 JSONArray put(int alphabetize, Object element)
Map of java.util.ArrayList.add(int, java.lang.Object), for compatibility to other JSON parsers.
 JSONArray put(int index, short value)
Method to place a brusque into the array.
 JSONArray put(long value)
Method to place a long into the array.
 JSONArray put(Map value)
Method to place a map into the array.
 JSONArray put(Map value, boolean includeSuperclass)
Method to place a map into the array.
 JSONArray put(Object element)
Map of java.util.ArrayList.add(coffee.lang.Object), for compatibility to other JSON parsers.
 JSONArray put(Object element, boolean includeSuperclass)
Map of coffee.util.ArrayList.add(java.lang.Object), for compatibility to other JSON parsers.
 JSONArray put(short value)
Method to place a brusque into the array.
 Object fix(int index, Object chemical element)
 String toString()
Over-ridden toString() method.
 String toString(int indentDepth)
Function to return a string of JSON text with specified indention.
 String write()
Convert this object into a String of JSON text.
 String write(boolean verbose)
Catechumen this object into a String of JSON text, specifying verbosity.
 String write(int indentDepth)
Convert this array into a Cord of JSON text, specifying verbosity.
 OutputStream write(OutputStream os)
Convert this object into a stream of JSON text.
 OutputStream write(OutputStream os, boolean verbose)
Convert this object into a stream of JSON text.
 OutputStream write(OutputStream bone, int indentDepth)
Convert this object into a String of JSON text, specifying how many spaces should be used for each indent level.
 Writer write(Writer writer)
Convert this object into a stream of JSON text.
 Writer write(Writer author, boolean verbose)
Catechumen this object into a stream of JSON text, specifying verbosity.
 Writer write(Writer writer, int indentDepth)
Catechumen this array into a stream of JSON text, specifying verbosity.
Methods inherited from course coffee.util.ArrayList
articulate, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, size, toArray, toArray, trimToSize
Methods inherited from class coffee.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, expect, wait
Methods inherited from interface coffee.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
Constructor Item

JSONArray

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

JSONArray

public        JSONArray(int initialCapacity)
Create a new instance of this class with the specified initial chapters.
Parameters:
initialCapacity - The initial size to define the array equally.

JSONArray

public        JSONArray(Collection col)           throws JSONException
Create a new instance of this class based off the contents of the passed in collection
Parameters:
col - The Collection of objects to add into this array.
Throws:
JSONException - Thrown when objects in the collection are not JSONable.
NullPointerException - Thrown if col is zero.

JSONArray

public        JSONArray(Object[] elems)           throws JSONException
Create a new case of this class based off the contents of the passed object array.
Parameters:
elems - The strings to add to a new JSONArray
Throws:
JSONException - Thrown when objects in the array are not JSONable.

JSONArray

public        JSONArray(Object[] elems,                  boolean includeSuperclass)           throws JSONException
Create a new instance of this form based off the contents of the passed object array.
Parameters:
elems - The strings to add to a new JSONArray
includeSuperclass - For JavaBeans, include all superclass info.
Throws:
JSONException - Thrown when objects in the array are not JSONable.

JSONArray

public        JSONArray(Collection col,                  boolean includeSuperclass)           throws JSONException
Create a new instance of this class based off the contents of the passed in collection
Parameters:
col - The Collection of objects to add into this array.
includeSuperclass - For JavaBeans, include all superclass info.
Throws:
JSONException - Thrown when objects in the collection are not JSONable. &throws NullPointerException Thrown if col is naught.

JSONArray

public        JSONArray(Cord str)           throws JSONException
Create a new instance of this course from the provided JSON object string. Note: This is the same equally calling new JSONArray(str, simulated); Parsing in not-strict fashion.
Parameters:
str - The JSON array string to parse.
Throws:
JSONException - Thrown when the string passed is null, or malformed JSON..

JSONArray

public        JSONArray(String str,                  boolean strict)           throws JSONException
Create a new instance of this form from the provided JSON object cord.
Parameters:
str - The JSON assortment cord to parse.
strict - Boolean denoting if the JSON should be parsed n strict fashion, significant unquoted strings and comments are not allowed.
Throws:
JSONException - Thrown when the string passed is null, or malformed JSON..

JSONArray

public        JSONArray(Reader rdr)           throws JSONException
Create a new instance of this course from the information provided from the reader. The reader content must be a JSON array string. Note: The reader volition not be airtight, that is left to the caller. Annotation: This is the same equally calling new JSONArray(rdr, faux); Parsing in non-strict mode.
Parameters:
rdr - The Reader from which to read the JSON array cord to parse.
Throws:
JSONException - Thrown when the string passed is cipher, or malformed JSON..

JSONArray

public        JSONArray(Reader rdr,                  boolean strict)           throws JSONException
Create a new instance of this grade from the data provided from the reader. The reader content must be a JSON assortment cord. Note: The reader will not be closed, that is left to the caller.
Parameters:
rdr - The Reader from which to read the JSON array string to parse.
strict - Boolean denoting if the JSON should exist parsed n strict mode, meaning unquoted strings and comments are not allowed.
Throws:
JSONException - Thrown when the cord passed is cypher, or malformed JSON..

JSONArray

public        JSONArray(InputStream is)           throws JSONException
Create a new case of this class from the information provided from the input stream. The stream content must be a JSON assortment string. Note: The input stream content is assumed to exist UTF-8 encoded. Annotation: The InputStream will not be closed, that is left to the caller.
Parameters:
is - The InputStream from which to read the JSON array string to parse.
Throws:
JSONException - Thrown when the string passed is nothing, or malformed JSON..

JSONArray

public        JSONArray(InputStream is,                  boolean strict)           throws JSONException
Create a new instance of this class from the information provided from the input stream. The stream content must be a JSON array string. Notation: The input stream content is causeless to be UTF-8 encoded. Notation: The InputStream will non be closed, that is left to the caller.
Parameters:
is - The InputStream from which to read the JSON array string to parse.
strict - Boolean denoting if the JSON should be parsed n strict mode, meaning unquoted strings and comments are not allowed.
Throws:
JSONException - Thrown when the string passed is nil, or malformed JSON..
Method Detail

getIndex

public Object        getIndex(int alphabetize)                 throws JSONException
Function to become a JSONArray entry at a specified index.
Parameters:
alphabetize - The position in the rray to fetch the object from
Throws:
JSONException - Thrown if the index is exterior the array bounds.

add together

public void        add(int index,                 Object element)
Specified by:
add in interface List
Overrides:
add in class ArrayList

add

public boolean        add together(Object element,                    boolean includeSuperclass)

add

public boolean        add(Object chemical element)
Specified past:
add together in interface Drove
Specified by:
add in interface List
Overrides:
add in class ArrayList

addAll

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

addAll

public boolean        addAll(int alphabetize,                       Collection collection)
Specified by:
addAll in interface Listing
Overrides:
addAll in class ArrayList

fix

public Object        set up(int index,                   Object element)
Specified past:
gear up in interface List
Overrides:
set in grade ArrayList

put

public JSONArray        put(int alphabetize,                      Object element)               throws JSONException
Map of java.util.ArrayList.add(int, java.lang.Object), for compatibility to other JSON parsers.
Returns:
A reference to this array instance.
Throws:
JSONException - in the instance of index out of premises, etc.
See Likewise:
ArrayList.add(int, java.lang.Object)

put

public JSONArray        put(Object element)               throws JSONException
Map of coffee.util.ArrayList.add together(java.lang.Object), for compatibility to other JSON parsers.
Returns:
A reference to this array example.
Throws:
JSONException
See Likewise:
ArrayList.add(java.lang.Object)

put

public JSONArray        put(Object element,                      boolean includeSuperclass)               throws JSONException
Map of java.util.ArrayList.add(java.lang.Object), for compatibility to other JSON parsers.
Returns:
A reference to this array case.
Throws:
JSONException
See Also:
ArrayList.add together(coffee.lang.Object)

put

public JSONArray        put(int alphabetize,                      Map value)               throws JSONException
Method to place a coffee.util.Map instance in the array. It will convert the map to a JSONObject if necessary.
Parameters:
index - The position in the array to place the Map (or coverted map).
value - An instance of a java.util.Map to insert into the array. Will catechumen to JSONObject if necessary.
Returns:
A reference to this array instance.
Throws:
JSONException - Thrown if the map cannot be converted to something JSONAble or the alphabetize is out of bounds.

put

public JSONArray        put(int index,                      Map value,                      boolean includeSuperclass)               throws JSONException
Method to place a java.util.Map instance in the array. Information technology will catechumen the map to a JSONObject if necessary.
Parameters:
index - The position in the array to place the Map (or coverted map).
value - An instance of a coffee.util.Map to insert into the array. Will catechumen to JSONObject if necessary.
Returns:
A reference to this array instance.
Throws:
JSONException - Thrown if the map cannot be converted to something JSONAble or the index is out of bounds.

put

public JSONArray        put(Map value)               throws JSONException
Method to place a map into the array. It will convert the map to a JSONObject if necessary.
Parameters:
value - An instance of a java.util.Map to insert into the array. Will catechumen to JSONObject if necessary.
Returns:
A reference to this assortment case.
Throws:
JSONException - Thrown if the map cannot be converted to something JSONAble.

put

public JSONArray        put(Map value,                      boolean includeSuperclass)               throws JSONException
Method to identify a map into the assortment. It will convert the map to a JSONObject if necessary.
Parameters:
value - An instance of a java.util.Map to insert into the array. Will convert to JSONObject if necessary.
Returns:
A reference to this array instance.
Throws:
JSONException - Thrown if the map cannot be converted to something JSONAble.

put

public JSONArray        put(int index,                      Collection value)               throws JSONException
Method to place a map into the array. It will convert the map to a JSONArray if necessary.
Parameters:
index - The position in the array to place the Collection.
value - An instance of a java.util.Collection to insert into the array. Volition catechumen to JSONArray if necessary.
Returns:
A reference to this array instance.
Throws:
JSONException - Thrown if the drove cannot be converted to something JSONAble or the index is out of bounds.

put

public JSONArray        put(int alphabetize,                      Collection value,                      boolean includeSuperclass)               throws JSONException
Method to place a map into the array. Information technology volition convert the map to a JSONArray if necessary.
Parameters:
index - The position in the assortment to place the Collection.
value - An instance of a java.util.Collection to insert into the array. Will convert to JSONArray if necessary.
Returns:
A reference to this assortment example.
Throws:
JSONException - Thrown if the collection cannot be converted to something JSONAble or the index is out of bounds.

put

public JSONArray        put(Drove value)               throws JSONException
Method to place a map into the assortment. It will convert the map to a JSONArray if necessary.
Parameters:
value - An case of a java.util.Collection to insert into the array. Will convert to JSONArray if necessary.
Returns:
A reference to this assortment instance.
Throws:
JSONException - Thrown if the drove cannot be converted to something JSONAble.

put

public JSONArray        put(Drove value,                      boolean includeSuperclass)               throws JSONException
Method to place a map into the array. It will convert the map to a JSONArray if necessary.
Parameters:
value - An instance of a java.util.Collection to insert into the array. Will catechumen to JSONArray if necessary.
Returns:
A reference to this assortment example.
Throws:
JSONException - Thrown if the collection cannot be converted to something JSONAble.

put

public JSONArray        put(long value)
Method to place a long into the array.
Parameters:
value - A long
Returns:
A reference to this array instance.

put

public JSONArray        put(int index,                      long value)
Method to place a long into the assortment.
Parameters:
index - The position in the array to identify the long.
value - A long
Returns:
A reference to this assortment instance.

put

public JSONArray        put(int value)
Method to place a int into the array.
Parameters:
value - An int
Returns:
A reference to this array instance.

put

public JSONArray        put(int index,                      int value)
Method to place an int into the array.
Parameters:
index - The position in the array to place the int.
value - An int
Returns:
A reference to this array example.

put

public JSONArray        put(brusque value)
Method to place a short into the assortment.
Parameters:
value - A curt
Returns:
A reference to this array case.

put

public JSONArray        put(int index,                      brusque value)
Method to place a short into the assortment.
Parameters:
alphabetize - The position in the array to place the brusk.
value - A short
Returns:
A reference to this array instance.

put

public JSONArray        put(double value)
Method to place a double into the array.
Parameters:
value - A double
Returns:
A reference to this array instance.

put

public JSONArray        put(int index,                      double value)
Method to place a double into the array.
Parameters:
index - The position in the array to place the double.
value - A double
Returns:
A reference to this array instance.

put

public JSONArray        put(boolean value)
Method to place a int into the array.
Parameters:
value - A boolean
Returns:
A reference to this array instance.

put

public JSONArray        put(int index,                      boolean value)
Method to identify a boolean into the assortment.
Parameters:
index - The position in the array to place the int.
value - A boolean
Returns:
A reference to this array instance.

getBoolean

public boolean        getBoolean(int index)                    throws JSONException
Part to obtain a value at the specified index as a boolean.
Parameters:
index - The index of the item to retrieve.
Returns:
boolean value.
Throws:
JSONException - if the index is outside the range or if the type at the position was not Boolean or a string of 'true' or 'false'

getDouble

public double        getDouble(int index)                  throws JSONException
Function to obtain a value at the specified alphabetize as a double.
Parameters:
index - The index of the particular to retrieve.
Returns:
double value.
Throws:
JSONException - if the index is outside the range or if the type at the position was not Number.

getLong

public long        getLong(int index)              throws JSONException
Function to obtain a value at the specified index as a long.
Parameters:
index - The index of the particular to call up.
Returns:
long value.
Throws:
JSONException - if the index is outside the range or if the type at the position was not Number.

getInt

public int        getInt(int index)            throws JSONException
Function to obtain a value at the specified index as an int.
Parameters:
alphabetize - The index of the particular to recollect.
Returns:
int value.
Throws:
JSONException - if the index is outside the range or if the type at the position was not Number.

getShort

public short        getShort(int index)                throws JSONException
Office to obtain a value at the specified index equally a short.
Parameters:
alphabetize - The index of the particular to retrieve.
Returns:
curt value.
Throws:
JSONException - if the alphabetize is outside the range or if the type at the position was not Number.

getString

public Cord        getString(int alphabetize)                  throws JSONException
Role to obtain a value at the specified index as a string.
Parameters:
index - The alphabetize of the item to recollect.
Returns:
cord value.
Throws:
JSONException - if the index is outside the range or if the type at the position was not an object with a toString() role..

getJSONObject

public JSONObject        getJSONObject(int index)                          throws JSONException
Utility method to obtain the specified key as a JSONObject Only values that are instances of JSONObject volition exist returned. A cipher will generate an exception.
Parameters:
index - The alphabetize to look up. throws JSONException Thrown when the blazon returned by get(key) is not a JSONObject instance.
Returns:
A JSONObject value if the value stored for key is an instance or subclass of JSONObject.
Throws:
JSONException

getJSONArray

public JSONArray        getJSONArray(int index)                        throws JSONException
Utility method to obtain the specified index as a JSONArray Only values that are instances of JSONArray will be returned. A null will generate an exception.
Parameters:
index - The alphabetize to await up. throws JSONException Thrown when the blazon returned by go(key) is not a Long example, or cannot be converted to a long..
Returns:
A JSONArray value if the value stored for key is an instance or bracket of JSONArray.
Throws:
JSONException

isNull

public boolean        isNull(int index)
Utility function for testing if an chemical element at index 'idx' is cypher or not.
Returns:
boolean indicating if an alphabetize is null or non. Will also return true for indexes outside the size of the array.

length

public int        length()
Utility part that maps ArrayList.size() to length, for compatibility to other JSON parsers.
Returns:
The number of elements in this JSONArray.

write

public OutputStream        write(OutputStream os)                    throws JSONException
Convert this object into a stream of JSON text. Aforementioned as calling write(os,false);
Specified past:
write in interface JSONArtifact
Parameters:
os - The output stream to write data to.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public OutputStream        write(OutputStream os,                           boolean verbose)                    throws JSONException
Convert this object into a stream of JSON text. Same as calling write(author,false);
Specified past:
write in interface JSONArtifact
Parameters:
os - The output stream to write information to. Output stream characters will be serialized as UTF-8.
verbose - Whether or not to write the JSON text in a verbose format.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public OutputStream        write(OutputStream os,                           int indentDepth)                    throws JSONException
Catechumen this object into a Cord of JSON text, specifying how many spaces should be used for each indent level. Output stream characters will be serialized as UTF-8.
Specified by:
write in interface JSONArtifact
Parameters:
indentDepth - How many spaces to use for each indent level. Should be i to eight. Less than i means no intending, greater than viii and it will just use tab.
Returns:
The passed in OutputStream.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public Author        write(Writer writer)              throws JSONException
Convert this object into a stream of JSON text. Same as calling write(writer,false);
Specified past:
write in interface JSONArtifact
Parameters:
writer - The writer which to write the JSON text to.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public Author        write(Writer author,                     boolean verbose)              throws JSONException
Convert this object into a stream of JSON text, specifying verbosity.
Specified by:
write in interface JSONArtifact
Parameters:
writer - The writer which to write the JSON text to.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public Writer        write(Author writer,                     int indentDepth)              throws JSONException
Catechumen this array into a stream of JSON text, specifying verbosity.
Specified past:
write in interface JSONArtifact
Parameters:
writer - The writer which to write the JSON text to.
indentDepth - How many spaces to use for each indent level. Should exist one to eight.
Returns:
The passed in writer.
Throws:
JSONException - Thrown on IO errors during serialization.

write

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

write

public String        write(int indentDepth)              throws JSONException
Convert this array into a Cord of JSON text, specifying verbosity.
Specified by:
write in interface JSONArtifact
Parameters:
indentDepth - How many spaces to use for each indent level. Should be one to eight.
Throws:
JSONException - Thrown on IO errors during serialization.

write

public String        write()              throws JSONException
Convert this object into a String of JSON text. Aforementioned as write(false);
Specified by:
write in interface JSONArtifact
Throws:
JSONException - Thrown on IO errors during serialization.

toString

public Cord        toString()
Over-ridden toString() method. Returns the same value as write(), which is a meaty JSON String. If an error occurs in the serialization, the return will be of format: JSON Generation Error: []
Overrides:
toString in class AbstractCollection

toString

public String        toString(int indentDepth)                 throws JSONException
Function to return a string of JSON text with specified indention. Returns the same value every bit write(indentDepth). If an error occurs in the serialization, the return will be of format: JSON Generation Error: []
Throws:
JSONException - Thrown if an mistake occurs during JSON generation.

join

public String        join(String str)
Method to mimic the behavior of the JavaScript array join function
Parameters:
str - The string delimiter to place betwixt joined array elements in the output string.
Returns:
A string of all the elements joined together.

opt

public Object        opt(int index)
Method to become the object at that position, or zippo if outside the assortment range.
Parameters:
index - the assortment index to get
Returns:
- value or naught

opt

public Object        opt(int index,                   Object defaultValue)
Method to become the object at that position, or null if outside the assortment range.
Parameters:
index - the array alphabetize to get
defaultValue - the value to return if index is exterior the assortment.
Returns:
- value or defaultValue

optBoolean

public boolean        optBoolean(int alphabetize)
Method to obtain the value at index equally an boolean, or 'false' if outside the array.
Parameters:
index - the array alphabetize to go
Returns:
- value or faux

optBoolean

public boolean        optBoolean(int index,                           boolean defaultValue)
Method to obtain the value at alphabetize as an boolean, or 'defaultValue' if exterior the array.
Parameters:
alphabetize - The array alphabetize to get.
defaultValue - the value to return if alphabetize is outside the array.
Returns:
- value or fake

optInt

public int        optInt(int index)
Method to obtain the value at index as an int, or '0' if outside the array.
Parameters:
alphabetize - the array index to get
Returns:
- value or 0

optInt

public int        optInt(int index,                   int defaultValue)
Method to obtain the value at index as an int, or defaultValue if outside the array.
Parameters:
alphabetize - the array alphabetize to go
defaultValue - the value to return if alphabetize is outside the assortment.
Returns:
- value or 0

optLong

public long        optLong(int index)
Method to obtain the value at index equally a long, or '0' if exterior the assortment.
Parameters:
alphabetize - the assortment index to get
Returns:
- value or 0

optLong

public long        optLong(int index,                     long defaultValue)
Method to obtain the value at index as a long, or defaultValue if exterior the array.
Parameters:
alphabetize - the array index to get
defaultValue - the value to return if index is outside the array. five* @return - value or defaultValue

optShort

public short        optShort(int index)
Method to obtain the value at index every bit a short, or '0' if outside the array.
Parameters:
alphabetize - the array index to get
Returns:
- value or 0

optShort

public short        optShort(int index,                       brusque defaultValue)
Method to obtain the value at index as a short, or '0' if outside the assortment.
Parameters:
index - the array alphabetize to get
defaultValue - the value to return if index is outside the array.
Returns:
- value or defaultValue

optDouble

public double        optDouble(int index)
Method to obtain the value at index as a double, or Double.NaN if exterior the array.
Parameters:
index - the array index to go
Returns:
- value or Double.NaN

optDouble

public double        optDouble(int index,                         double defaultValue)
Method to obtain the value at alphabetize as a double, or Double.NaN if exterior the array.
Parameters:
alphabetize - the array index to get
defaultValue - the value to render if index is outside the array.
Returns:
- value or defaultValue

optString

public String        optString(int alphabetize)
Method to obtain the value at index as a Cord, or null if outside the assortment.
Parameters:
index - the array index to get
Returns:
- value or null

optString

public Cord        optString(int alphabetize,                         String defaultValue)
Method to obtain the value at alphabetize every bit a String, or defaultValue if outside the array.
Parameters:
alphabetize - the assortment index to become
defaultValue - the value to render if alphabetize is outside the assortment.
Returns:
- value or defaultValue


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.

bowseralhas1980.blogspot.com

Source: https://wink.apache.org/documentation/1.2.0/api/org/apache/wink/json4j/JSONArray.html

0 Response to "Read From Inputstream and Convert to Json Object in Java"

Enviar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel