diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF deleted file mode 100644 index 025de46..0000000 --- a/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Archiver-Version: Plexus Archiver -Created-By: Apache Maven -Built-By: Benjamin -Build-Jdk: 1.8.0_05 - diff --git a/allclasses-frame.html b/docs/allclasses-frame.html similarity index 65% rename from allclasses-frame.html rename to docs/allclasses-frame.html index 0a63484..bcf41c4 100644 --- a/allclasses-frame.html +++ b/docs/allclasses-frame.html @@ -1,35 +1,41 @@ - - - -
- - -Copyright © 2016. All Rights Reserved.
- - + + + + + +| Modifier and Type | +Constant Field | +Value | +
|---|---|---|
+
+public static final String |
+CRLF |
+"\r\n" |
+
| Modifier and Type | +Constant Field | +Value | +
|---|---|---|
+
+public static final String |
+NULL_ATTR |
+"xsi:nil" |
+
+
+public static final String |
+TYPE_ATTR |
+"xsi:type" |
+
| Method and Description | -
|---|
| org.json.XML.stringToValue(String)
- Use
-JSONObject.stringToValue(String) instead. |
-
Copyright © 2016. All Rights Reserved.
- - + + + + + +| Constructor and Description | +
|---|
| org.json.XMLParserConfiguration(boolean)
+ This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
| org.json.XMLParserConfiguration(boolean, String)
+ This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
| org.json.XMLParserConfiguration(boolean, String, boolean)
+ This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed or marked private in a future release.
+ |
+
| org.json.XMLParserConfiguration(String)
+ This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-Each annotation type has its own separate page with the following sections:
-Each enum has its own separate page with the following sections:
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-These links take you to the next or previous class, interface, package, or related page.
-These links show and hide the HTML frames. All pages are available with or without frames.
-The All Classes link shows all classes and interfaces except non-static nested types.
-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-The Constant Field Values page lists the static final fields and their values.
-Copyright © 2016. All Rights Reserved.
- - + + + + + +Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+JSONString interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString(), JSONArray.toString(),
- and JSONWriter.value(Object).NULL object than to use Java's null value.JSONObject.stringToValue(String) instead.toJSONString method allows a class to produce its own JSON
- serialization.%hh sequences to single characters, and
- convert plus to space.true or the value
- false.Copyright © 2016. All Rights Reserved.
- - + + + + + +JSONPointer instance using the tokens previously set using the
+ JSONPointer.Builder.append(String) method calls.JSONPointer.Builder.Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as stringfalse), or they should be converted to
+ null(true)true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string)null.null or if there is no
+ value.JSONPointer instance.JSONPointer if an error occurs
+ during evaluating a pointer.JSONString interface allows a toJSONString()
+ method so that a class can change the behavior of
+ JSONObject.toString(), JSONArray.toString(),
+ and JSONWriter.value(Object).NULL object than to use Java's null value.Number value associated with a key, or null
+ if there is no such key or if the value is not a number.Number value associated with a key, or the default if there
+ is no such key or if the value is not a number.Number value associated with a key, or null
+ if there is no such key or if the value is not a number.Number value associated with a key, or the default if there
+ is no such key or if the value is not a number.jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer, or
+ returns null if the query fails due to a missing key.document.JSONObject.stringToValue(String).toJSONString method allows a class to produce its own JSON
+ serialization.%hh sequences to single characters, and
+ convert plus to space.true or the value
+ false.false), or they should be converted to
+ null(true)true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string)Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as stringpublic class CDL
-extends java.lang.Object
-- Each row of text represents a row in a table or a data record. Each row - ends with a NEWLINE character. Each row contains one or more values. - Values are separated by commas. A value can contain any character except - for comma, unless is is wrapped in single quotes or double quotes. -
- The first row usually contains the names of the columns. -
- A comma delimited list can be converted into a JSONArray of JSONObjects. - The names for the elements in the JSONObjects can be taken from the names - in the first row.
| Modifier and Type | -Method and Description | -
|---|---|
static JSONArray |
-rowToJSONArray(JSONTokener x)
-Produce a JSONArray of strings from a row of comma delimited values.
- |
-
static JSONObject |
-rowToJSONObject(JSONArray names,
- JSONTokener x)
-Produce a JSONObject from a row of comma delimited text, using a
- parallel JSONArray of strings to provides the names of the elements.
- |
-
static java.lang.String |
-rowToString(JSONArray ja)
-Produce a comma delimited text row from a JSONArray.
- |
-
static JSONArray |
-toJSONArray(JSONArray names,
- JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-toJSONArray(JSONArray names,
- java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-toJSONArray(JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static JSONArray |
-toJSONArray(java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static java.lang.String |
-toString(JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects.
- |
-
static java.lang.String |
-toString(JSONArray names,
- JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects using
- a provided list of names.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static JSONArray rowToJSONArray(JSONTokener x) - throws JSONException-
x - A JSONTokener of the source text.JSONExceptionpublic static JSONObject rowToJSONObject(JSONArray names, - JSONTokener x) - throws JSONException-
names - A JSONArray of names. This is commonly obtained from the
- first row of a comma delimited text file using the rowToJSONArray
- method.x - A JSONTokener of the source text.JSONExceptionpublic static java.lang.String rowToString(JSONArray ja)-
ja - A JSONArray of strings.public static JSONArray toJSONArray(java.lang.String string) - throws JSONException-
string - The comma delimited text.JSONExceptionpublic static JSONArray toJSONArray(JSONTokener x) - throws JSONException-
x - The JSONTokener containing the comma delimited text.JSONExceptionpublic static JSONArray toJSONArray(JSONArray names, - java.lang.String string) - throws JSONException-
names - A JSONArray of strings.string - The comma delimited text.JSONExceptionpublic static JSONArray toJSONArray(JSONArray names, - JSONTokener x) - throws JSONException-
names - A JSONArray of strings.x - A JSONTokener of the source text.JSONExceptionpublic static java.lang.String toString(JSONArray ja) - throws JSONException-
ja - A JSONArray of JSONObjects.JSONExceptionpublic static java.lang.String toString(JSONArray names, - JSONArray ja) - throws JSONException-
names - A JSONArray of strings.ja - A JSONArray of JSONObjects.JSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class CDL +extends Object+
+ Each row of text represents a row in a table or a data record. Each row + ends with a NEWLINE character. Each row contains one or more values. + Values are separated by commas. A value can contain any character except + for comma, unless is is wrapped in single quotes or double quotes. +
+ The first row usually contains the names of the columns. +
+ A comma delimited list can be converted into a JSONArray of JSONObjects. + The names for the elements in the JSONObjects can be taken from the names + in the first row.
| Modifier and Type | +Method and Description | +
|---|---|
static JSONArray |
+rowToJSONArray(JSONTokener x)
+Produce a JSONArray of strings from a row of comma delimited values.
+ |
+
static JSONObject |
+rowToJSONObject(JSONArray names,
+ JSONTokener x)
+Produce a JSONObject from a row of comma delimited text, using a
+ parallel JSONArray of strings to provides the names of the elements.
+ |
+
static String |
+rowToString(JSONArray ja)
+Produce a comma delimited text row from a JSONArray.
+ |
+
static JSONArray |
+toJSONArray(JSONArray names,
+ JSONTokener x)
+Produce a JSONArray of JSONObjects from a comma delimited text string
+ using a supplied JSONArray as the source of element names.
+ |
+
static JSONArray |
+toJSONArray(JSONArray names,
+ String string)
+Produce a JSONArray of JSONObjects from a comma delimited text string
+ using a supplied JSONArray as the source of element names.
+ |
+
static JSONArray |
+toJSONArray(JSONTokener x)
+Produce a JSONArray of JSONObjects from a comma delimited text string,
+ using the first row as a source of names.
+ |
+
static JSONArray |
+toJSONArray(String string)
+Produce a JSONArray of JSONObjects from a comma delimited text string,
+ using the first row as a source of names.
+ |
+
static String |
+toString(JSONArray ja)
+Produce a comma delimited text from a JSONArray of JSONObjects.
+ |
+
static String |
+toString(JSONArray names,
+ JSONArray ja)
+Produce a comma delimited text from a JSONArray of JSONObjects using
+ a provided list of names.
+ |
+
public static JSONArray rowToJSONArray(JSONTokener x) + throws JSONException+
x - A JSONTokener of the source text.JSONException - if a called function failspublic static JSONObject rowToJSONObject(JSONArray names, + JSONTokener x) + throws JSONException+
names - A JSONArray of names. This is commonly obtained from the
+ first row of a comma delimited text file using the rowToJSONArray
+ method.x - A JSONTokener of the source text.JSONException - if a called function failspublic static String rowToString(JSONArray ja)+
ja - A JSONArray of strings.public static JSONArray toJSONArray(String string) + throws JSONException+
string - The comma delimited text.JSONException - if a called function failspublic static JSONArray toJSONArray(JSONTokener x) + throws JSONException+
x - The JSONTokener containing the comma delimited text.JSONException - if a called function failspublic static JSONArray toJSONArray(JSONArray names, + String string) + throws JSONException+
names - A JSONArray of strings.string - The comma delimited text.JSONException - if a called function failspublic static JSONArray toJSONArray(JSONArray names, + JSONTokener x) + throws JSONException+
names - A JSONArray of strings.x - A JSONTokener of the source text.JSONException - if a called function failspublic static String toString(JSONArray ja) + throws JSONException+
ja - A JSONArray of JSONObjects.JSONException - if a called function failspublic static String toString(JSONArray names, + JSONArray ja) + throws JSONException+
names - A JSONArray of strings.ja - A JSONArray of JSONObjects.JSONException - if a called function failspublic class Cookie
-extends java.lang.Object
-| Modifier and Type | -Method and Description | -
|---|---|
static java.lang.String |
-escape(java.lang.String string)
-Produce a copy of a string in which the characters '+', '%', '=', ';'
- and control characters are replaced with "%hh".
- |
-
static JSONObject |
-toJSONObject(java.lang.String string)
-Convert a cookie specification string into a JSONObject.
- |
-
static java.lang.String |
-toString(JSONObject jo)
-Convert a JSONObject into a cookie specification string.
- |
-
static java.lang.String |
-unescape(java.lang.String string)
-Convert
-%hh sequences to single characters, and
- convert plus to space. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static java.lang.String escape(java.lang.String string)-
string - The source string.public static JSONObject toJSONObject(java.lang.String string) - throws JSONException-
string - The cookie specification string.JSONExceptionpublic static java.lang.String toString(JSONObject jo) - throws JSONException-
jo - A JSONObjectJSONExceptionpublic static java.lang.String unescape(java.lang.String string)-
%hh sequences to single characters, and
- convert plus to space.string - A string that may contain
- + (plus) and
- %hh sequences.Copyright © 2016. All Rights Reserved.
- - + + + + + +public class Cookie +extends Object+
| Modifier and Type | +Method and Description | +
|---|---|
static String |
+escape(String string)
+Produce a copy of a string in which the characters '+', '%', '=', ';'
+ and control characters are replaced with "%hh".
+ |
+
static JSONObject |
+toJSONObject(String string)
+Convert a cookie specification string into a JSONObject.
+ |
+
static String |
+toString(JSONObject jo)
+Convert a JSONObject into a cookie specification string.
+ |
+
static String |
+unescape(String string)
+Convert
+%hh sequences to single characters, and
+ convert plus to space. |
+
public static String escape(String string)+
string - The source string.public static JSONObject toJSONObject(String string)+
Boolean.TRUE will be used for these).
+ The name will be stored under the key "name", and the value will be
+ stored under the key "value". This method does not do checking or
+ validation of the parameters. It only converts the cookie string into
+ a JSONObject. All attribute names are converted to lower case keys in the
+ JSONObject (HttpOnly => httponly). If an attribute is specified more than
+ once, only the value found closer to the end of the cookie-string is kept.string - The cookie specification string.JSONException - If there is an error parsing the Cookie String.
+ Cookie strings must have at least one '=' character and the 'name'
+ portion of the cookie must not be blank.public static String toString(JSONObject jo) + throws JSONException+
jo - A JSONObjectJSONException - thrown if the cookie has no name.public class CookieList
-extends java.lang.Object
-| Constructor and Description | -
|---|
CookieList() |
-
| Modifier and Type | -Method and Description | -
|---|---|
static JSONObject |
-toJSONObject(java.lang.String string)
-Convert a cookie list into a JSONObject.
- |
-
static java.lang.String |
-toString(JSONObject jo)
-Convert a JSONObject into a cookie list.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static JSONObject toJSONObject(java.lang.String string) - throws JSONException-
string - A cookie list stringJSONExceptionpublic static java.lang.String toString(JSONObject jo) - throws JSONException-
jo - A JSONObjectJSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class CookieList +extends Object+
| Constructor and Description | +
|---|
CookieList() |
+
| Modifier and Type | +Method and Description | +
|---|---|
static JSONObject |
+toJSONObject(String string)
+Convert a cookie list into a JSONObject.
+ |
+
static String |
+toString(JSONObject jo)
+Convert a JSONObject into a cookie list.
+ |
+
public static JSONObject toJSONObject(String string) + throws JSONException+
string - A cookie list stringJSONException - if a called function failspublic static String toString(JSONObject jo) + throws JSONException+
jo - A JSONObjectJSONException - if a called function failspublic class HTTP
-extends java.lang.Object
-| Modifier and Type | -Field and Description | -
|---|---|
static java.lang.String |
-CRLF
-Carriage return/line feed.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
static JSONObject |
-toJSONObject(java.lang.String string)
-Convert an HTTP header string into a JSONObject.
- |
-
static java.lang.String |
-toString(JSONObject jo)
-Convert a JSONObject into an HTTP header.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static final java.lang.String CRLF-
public static JSONObject toJSONObject(java.lang.String string) - throws JSONException-
{
- Method: "POST" (for example),
- "Request-URI": "/" (for example),
- "HTTP-Version": "HTTP/1.1" (for example)
- }
- A response header will contain
- {
- "HTTP-Version": "HTTP/1.1" (for example),
- "Status-Code": "200" (for example),
- "Reason-Phrase": "OK" (for example)
- }
- In addition, the other parameters in the header will be captured, using
- the HTTP field names as JSON names, so that - Date: Sun, 26 May 2002 18:06:04 GMT - Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s - Cache-Control: no-cache- become -
{...
- Date: "Sun, 26 May 2002 18:06:04 GMT",
- Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
- "Cache-Control": "no-cache",
- ...}
- It does no further checking or conversion. It does not parse dates.
- It does not do '%' transforms on URLs.string - An HTTP header string.JSONExceptionpublic static java.lang.String toString(JSONObject jo) - throws JSONException-
{
- Method: "POST" (for example),
- "Request-URI": "/" (for example),
- "HTTP-Version": "HTTP/1.1" (for example)
- }
- A response header must contain
- {
- "HTTP-Version": "HTTP/1.1" (for example),
- "Status-Code": "200" (for example),
- "Reason-Phrase": "OK" (for example)
- }
- Any other members of the JSONObject will be output as HTTP fields.
- The result will end with two CRLF pairs.jo - A JSONObjectJSONException - if the object does not contain enough
- information.Copyright © 2016. All Rights Reserved.
- - + + + + + +public class HTTP +extends Object+
| Modifier and Type | +Field and Description | +
|---|---|
static String |
+CRLF
+Carriage return/line feed.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
static JSONObject |
+toJSONObject(String string)
+Convert an HTTP header string into a JSONObject.
+ |
+
static String |
+toString(JSONObject jo)
+Convert a JSONObject into an HTTP header.
+ |
+
public static final String CRLF+
public static JSONObject toJSONObject(String string) + throws JSONException+
{
+ Method: "POST" (for example),
+ "Request-URI": "/" (for example),
+ "HTTP-Version": "HTTP/1.1" (for example)
+ }
+ A response header will contain
+ {
+ "HTTP-Version": "HTTP/1.1" (for example),
+ "Status-Code": "200" (for example),
+ "Reason-Phrase": "OK" (for example)
+ }
+ In addition, the other parameters in the header will be captured, using
+ the HTTP field names as JSON names, so that
+ Date: Sun, 26 May 2002 18:06:04 GMT
+ Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
+ Cache-Control: no-cache
+ become
+
+ Date: "Sun, 26 May 2002 18:06:04 GMT",
+ Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
+ "Cache-Control": "no-cache",
+ ...
+ It does no further checking or conversion. It does not parse dates.
+ It does not do '%' transforms on URLs.string - An HTTP header string.JSONException - if a called function failspublic static String toString(JSONObject jo) + throws JSONException+
{
+ Method: "POST" (for example),
+ "Request-URI": "/" (for example),
+ "HTTP-Version": "HTTP/1.1" (for example)
+ }
+ A response header must contain
+ {
+ "HTTP-Version": "HTTP/1.1" (for example),
+ "Status-Code": "200" (for example),
+ "Reason-Phrase": "OK" (for example)
+ }
+ Any other members of the JSONObject will be output as HTTP fields.
+ The result will end with two CRLF pairs.jo - A JSONObjectJSONException - if the object does not contain enough
+ information.public class HTTPTokener -extends JSONTokener-
| Constructor and Description | -
|---|
HTTPTokener(java.lang.String string)
-Construct an HTTPTokener from a string.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
java.lang.String |
-nextToken()
-Get the next token or string.
- |
-
back, dehexchar, end, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, skipTo, syntaxError, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic HTTPTokener(java.lang.String string)-
string - A source string.public java.lang.String nextToken() - throws JSONException-
JSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class HTTPTokener +extends JSONTokener+
| Constructor and Description | +
|---|
HTTPTokener(String string)
+Construct an HTTPTokener from a string.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
String |
+nextToken()
+Get the next token or string.
+ |
+
back, dehexchar, end, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, skipTo, syntaxError, syntaxError, toStringpublic HTTPTokener(String string)+
string - A source string.public String nextToken() + throws JSONException+
JSONException - if a syntax error occurspublic class JSONArray
-extends java.lang.Object
-implements java.lang.Iterable<java.lang.Object>
-get and opt
- methods for accessing the values by index, and put methods for
- adding or replacing values. The values can be any of these types:
- Boolean, JSONArray, JSONObject,
- Number, String, or the
- JSONObject.NULL object.
-
- The constructor can convert a JSON text into a Java object. The
- toString method converts to JSON text.
-
- A get method returns a value if one can be found, and throws an
- exception if one cannot be found. An opt method returns a
- default value instead of throwing an exception, and so is useful for
- obtaining optional values.
-
- The generic get() and opt() methods return an
- object which you can cast or query for type. There are also typed
- get and opt methods that do type checking and type
- coercion for you.
-
- The texts produced by the toString methods strictly conform to
- JSON syntax rules. The constructors are more forgiving in the texts they will
- accept:
-
, (comma) may appear just
- before the closing bracket.null value will be inserted when there is ,
- (comma) elision.' (single
- quote).{ } [ ] / \ : , # and if they do not look like numbers and
- if they are not the reserved words true, false, or
- null.| Constructor and Description | -
|---|
JSONArray()
-Construct an empty JSONArray.
- |
-
JSONArray(java.util.Collection<?> collection)
-Construct a JSONArray from a Collection.
- |
-
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONArray(java.lang.Object array)
-Construct a JSONArray from an array
- |
-
JSONArray(java.lang.String source)
-Construct a JSONArray from a source JSON text.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
java.lang.Object |
-get(int index)
-Get the object value associated with an index.
- |
-
java.math.BigDecimal |
-getBigDecimal(int index)
-Get the BigDecimal value associated with an index.
- |
-
java.math.BigInteger |
-getBigInteger(int index)
-Get the BigInteger value associated with an index.
- |
-
boolean |
-getBoolean(int index)
-Get the boolean value associated with an index.
- |
-
double |
-getDouble(int index)
-Get the double value associated with an index.
- |
-
<E extends java.lang.Enum<E>> |
-getEnum(java.lang.Class<E> clazz,
- int index)
-Get the enum value associated with an index.
- |
-
int |
-getInt(int index)
-Get the int value associated with an index.
- |
-
JSONArray |
-getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONObject |
-getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
long |
-getLong(int index)
-Get the long value associated with an index.
- |
-
java.lang.String |
-getString(int index)
-Get the string associated with an index.
- |
-
boolean |
-isNull(int index)
-Determine if the value is null.
- |
-
java.util.Iterator<java.lang.Object> |
-iterator() |
-
java.lang.String |
-join(java.lang.String separator)
-Make a string from the contents of this JSONArray.
- |
-
int |
-length()
-Get the number of elements in the JSONArray, included nulls.
- |
-
java.lang.Object |
-opt(int index)
-Get the optional object value associated with an index.
- |
-
java.math.BigDecimal |
-optBigDecimal(int index,
- java.math.BigDecimal defaultValue)
-Get the optional BigDecimal value associated with an index.
- |
-
java.math.BigInteger |
-optBigInteger(int index,
- java.math.BigInteger defaultValue)
-Get the optional BigInteger value associated with an index.
- |
-
boolean |
-optBoolean(int index)
-Get the optional boolean value associated with an index.
- |
-
boolean |
-optBoolean(int index,
- boolean defaultValue)
-Get the optional boolean value associated with an index.
- |
-
double |
-optDouble(int index)
-Get the optional double value associated with an index.
- |
-
double |
-optDouble(int index,
- double defaultValue)
-Get the optional double value associated with an index.
- |
-
<E extends java.lang.Enum<E>> |
-optEnum(java.lang.Class<E> clazz,
- int index)
-Get the enum value associated with a key.
- |
-
<E extends java.lang.Enum<E>> |
-optEnum(java.lang.Class<E> clazz,
- int index,
- E defaultValue)
-Get the enum value associated with a key.
- |
-
int |
-optInt(int index)
-Get the optional int value associated with an index.
- |
-
int |
-optInt(int index,
- int defaultValue)
-Get the optional int value associated with an index.
- |
-
JSONArray |
-optJSONArray(int index)
-Get the optional JSONArray associated with an index.
- |
-
JSONObject |
-optJSONObject(int index)
-Get the optional JSONObject associated with an index.
- |
-
long |
-optLong(int index)
-Get the optional long value associated with an index.
- |
-
long |
-optLong(int index,
- long defaultValue)
-Get the optional long value associated with an index.
- |
-
java.lang.String |
-optString(int index)
-Get the optional string value associated with an index.
- |
-
java.lang.String |
-optString(int index,
- java.lang.String defaultValue)
-Get the optional string associated with an index.
- |
-
JSONArray |
-put(boolean value)
-Append a boolean value.
- |
-
JSONArray |
-put(java.util.Collection<?> value)
-Put a value in the JSONArray, where the value will be a JSONArray which
- is produced from a Collection.
- |
-
JSONArray |
-put(double value)
-Append a double value.
- |
-
JSONArray |
-put(int value)
-Append an int value.
- |
-
JSONArray |
-put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-put(int index,
- java.util.Collection<?> value)
-Put a value in the JSONArray, where the value will be a JSONArray which
- is produced from a Collection.
- |
-
JSONArray |
-put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-put(int index,
- java.util.Map<?,?> value)
-Put a value in the JSONArray, where the value will be a JSONObject that
- is produced from a Map.
- |
-
JSONArray |
-put(int index,
- java.lang.Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONArray |
-put(long value)
-Append an long value.
- |
-
JSONArray |
-put(java.util.Map<?,?> value)
-Put a value in the JSONArray, where the value will be a JSONObject which
- is produced from a Map.
- |
-
JSONArray |
-put(java.lang.Object value)
-Append an object value.
- |
-
java.lang.Object |
-remove(int index)
-Remove an index and close the hole.
- |
-
boolean |
-similar(java.lang.Object other)
-Determine if two JSONArrays are similar.
- |
-
JSONObject |
-toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
java.lang.String |
-toString()
-Make a JSON text of this JSONArray.
- |
-
java.lang.String |
-toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONArray.
- |
-
java.io.Writer |
-write(java.io.Writer writer)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
java.io.Writer |
-write(java.io.Writer writer,
- int indentFactor,
- int indent)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic JSONArray()-
public JSONArray(JSONTokener x) - throws JSONException-
x - A JSONTokenerJSONException - If there is a syntax error.public JSONArray(java.lang.String source) - throws JSONException-
source - A string that begins with [ (left
- bracket) and ends with ]
- (right bracket).JSONException - If there is a syntax error.public JSONArray(java.util.Collection<?> collection)-
collection - A Collection.public JSONArray(java.lang.Object array) - throws JSONException-
JSONException - If not an array.public java.util.Iterator<java.lang.Object> iterator()-
iterator in interface java.lang.Iterable<java.lang.Object>public java.lang.Object get(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index.public boolean getBoolean(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index or if the value is not
- convertible to boolean.public double getDouble(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
- to a number.public <E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> clazz, - int index) - throws JSONException-
clazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.JSONException - if the key is not found or if the value cannot be converted
- to an enum.public java.math.BigDecimal getBigDecimal(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
- to a BigDecimal.public java.math.BigInteger getBigInteger(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
- to a BigInteger.public int getInt(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value is not a number.public JSONArray getJSONArray(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index. or if the value is not a
- JSONArraypublic JSONObject getJSONObject(int index) - throws JSONException-
index - subscriptJSONException - If there is no value for the index or if the value is not a
- JSONObjectpublic long getLong(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
- to a number.public java.lang.String getString(int index) - throws JSONException-
index - The index must be between 0 and length() - 1.JSONException - If there is no string value for the index.public boolean isNull(int index)-
index - The index must be between 0 and length() - 1.public java.lang.String join(java.lang.String separator) - throws JSONException-
separator string is inserted between each element. Warning:
- This method assumes that the data structure is acyclical.separator - A string that will be inserted between the elements.JSONException - If the array contains an invalid number.public int length()-
public java.lang.Object opt(int index)-
index - The index must be between 0 and length() - 1.public boolean optBoolean(int index)-
index - The index must be between 0 and length() - 1.public boolean optBoolean(int index, - boolean defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - A boolean default.public double optDouble(int index)-
index - The index must be between 0 and length() - 1.public double optDouble(int index, - double defaultValue)-
index - subscriptdefaultValue - The default value.public int optInt(int index)-
index - The index must be between 0 and length() - 1.public int optInt(int index, - int defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - The default value.public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz, - int index)-
clazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz, - int index, - E defaultValue)-
clazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.defaultValue - The default in case the value is not foundpublic java.math.BigInteger optBigInteger(int index, - java.math.BigInteger defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - The default value.public java.math.BigDecimal optBigDecimal(int index, - java.math.BigDecimal defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - The default value.public JSONArray optJSONArray(int index)-
index - subscriptpublic JSONObject optJSONObject(int index)-
index - The index must be between 0 and length() - 1.public long optLong(int index)-
index - The index must be between 0 and length() - 1.public long optLong(int index, - long defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - The default value.public java.lang.String optString(int index)-
index - The index must be between 0 and length() - 1.public java.lang.String optString(int index, - java.lang.String defaultValue)-
index - The index must be between 0 and length() - 1.defaultValue - The default value.public JSONArray put(boolean value)-
value - A boolean value.public JSONArray put(java.util.Collection<?> value)-
value - A Collection value.public JSONArray put(double value) - throws JSONException-
value - A double value.JSONException - if the value is not finite.public JSONArray put(int value)-
value - An int value.public JSONArray put(long value)-
value - A long value.public JSONArray put(java.util.Map<?,?> value)-
value - A Map value.public JSONArray put(java.lang.Object value)-
value - An object value. The value should be a Boolean, Double,
- Integer, JSONArray, JSONObject, Long, or String, or the
- JSONObject.NULL object.public JSONArray put(int index, - boolean value) - throws JSONException-
index - The subscript.value - A boolean value.JSONException - If the index is negative.public JSONArray put(int index, - java.util.Collection<?> value) - throws JSONException-
index - The subscript.value - A Collection value.JSONException - If the index is negative or if the value is not finite.public JSONArray put(int index, - double value) - throws JSONException-
index - The subscript.value - A double value.JSONException - If the index is negative or if the value is not finite.public JSONArray put(int index, - int value) - throws JSONException-
index - The subscript.value - An int value.JSONException - If the index is negative.public JSONArray put(int index, - long value) - throws JSONException-
index - The subscript.value - A long value.JSONException - If the index is negative.public JSONArray put(int index, - java.util.Map<?,?> value) - throws JSONException-
index - The subscript.value - The Map value.JSONException - If the index is negative or if the the value is an invalid
- number.public JSONArray put(int index, - java.lang.Object value) - throws JSONException-
index - The subscript.value - The value to put into the array. The value should be a
- Boolean, Double, Integer, JSONArray, JSONObject, Long, or
- String, or the JSONObject.NULL object.JSONException - If the index is negative or if the the value is an invalid
- number.public java.lang.Object remove(int index)-
index - The index of the element to be removed.public boolean similar(java.lang.Object other)-
other - The other JSONArraypublic JSONObject toJSONObject(JSONArray names) - throws JSONException-
names - A JSONArray containing a list of key strings. These will be
- paired with the values.JSONException - If any of the names are null.public java.lang.String toString()-
- Warning: This method assumes that the data structure is acyclical.
toString in class java.lang.Objectpublic java.lang.String toString(int indentFactor) - throws JSONException-
indentFactor - The number of spaces to add to each level of indentation.[ (left
- bracket) and ending with ]
- (right bracket).JSONExceptionpublic java.io.Writer write(java.io.Writer writer) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
JSONExceptionpublic java.io.Writer write(java.io.Writer writer, - int indentFactor, - int indent) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
writer - Writes the serialized JSONindentFactor - The number of spaces to add to each level of indentation.indent - The indention of the top level.JSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONArray +extends Object +implements Iterable<Object>+
get and opt
+ methods for accessing the values by index, and put methods for
+ adding or replacing values. The values can be any of these types:
+ Boolean, JSONArray, JSONObject,
+ Number, String, or the
+ JSONObject.NULL object.
+
+ The constructor can convert a JSON text into a Java object. The
+ toString method converts to JSON text.
+
+ A get method returns a value if one can be found, and throws an
+ exception if one cannot be found. An opt method returns a
+ default value instead of throwing an exception, and so is useful for
+ obtaining optional values.
+
+ The generic get() and opt() methods return an
+ object which you can cast or query for type. There are also typed
+ get and opt methods that do type checking and type
+ coercion for you.
+
+ The texts produced by the toString methods strictly conform to
+ JSON syntax rules. The constructors are more forgiving in the texts they will
+ accept:
+
, (comma) may appear just
+ before the closing bracket.null value will be inserted when there is ,
+ (comma) elision.' (single
+ quote).{ } [ ] / \ : , # and if they do not look like numbers and
+ if they are not the reserved words true, false, or
+ null.| Constructor and Description | +
|---|
JSONArray()
+Construct an empty JSONArray.
+ |
+
JSONArray(Collection<?> collection)
+Construct a JSONArray from a Collection.
+ |
+
JSONArray(int initialCapacity)
+Construct a JSONArray with the specified initial capacity.
+ |
+
JSONArray(Iterable<?> iter)
+Construct a JSONArray from an Iterable.
+ |
+
JSONArray(JSONArray array)
+Construct a JSONArray from another JSONArray.
+ |
+
JSONArray(JSONTokener x)
+Construct a JSONArray from a JSONTokener.
+ |
+
JSONArray(Object array)
+Construct a JSONArray from an array.
+ |
+
JSONArray(String source)
+Construct a JSONArray from a source JSON text.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
Object |
+get(int index)
+Get the object value associated with an index.
+ |
+
BigDecimal |
+getBigDecimal(int index)
+Get the BigDecimal value associated with an index.
+ |
+
BigInteger |
+getBigInteger(int index)
+Get the BigInteger value associated with an index.
+ |
+
boolean |
+getBoolean(int index)
+Get the boolean value associated with an index.
+ |
+
double |
+getDouble(int index)
+Get the double value associated with an index.
+ |
+
<E extends Enum<E>> |
+getEnum(Class<E> clazz,
+ int index)
+Get the enum value associated with an index.
+ |
+
float |
+getFloat(int index)
+Get the float value associated with a key.
+ |
+
int |
+getInt(int index)
+Get the int value associated with an index.
+ |
+
JSONArray |
+getJSONArray(int index)
+Get the JSONArray associated with an index.
+ |
+
JSONObject |
+getJSONObject(int index)
+Get the JSONObject associated with an index.
+ |
+
long |
+getLong(int index)
+Get the long value associated with an index.
+ |
+
Number |
+getNumber(int index)
+Get the Number value associated with a key.
+ |
+
String |
+getString(int index)
+Get the string associated with an index.
+ |
+
boolean |
+isEmpty()
+Check if JSONArray is empty.
+ |
+
boolean |
+isNull(int index)
+Determine if the value is
+null. |
+
Iterator<Object> |
+iterator() |
+
String |
+join(String separator)
+Make a string from the contents of this JSONArray.
+ |
+
int |
+length()
+Get the number of elements in the JSONArray, included nulls.
+ |
+
Object |
+opt(int index)
+Get the optional object value associated with an index.
+ |
+
BigDecimal |
+optBigDecimal(int index,
+ BigDecimal defaultValue)
+Get the optional BigDecimal value associated with an index.
+ |
+
BigInteger |
+optBigInteger(int index,
+ BigInteger defaultValue)
+Get the optional BigInteger value associated with an index.
+ |
+
boolean |
+optBoolean(int index)
+Get the optional boolean value associated with an index.
+ |
+
boolean |
+optBoolean(int index,
+ boolean defaultValue)
+Get the optional boolean value associated with an index.
+ |
+
double |
+optDouble(int index)
+Get the optional double value associated with an index.
+ |
+
double |
+optDouble(int index,
+ double defaultValue)
+Get the optional double value associated with an index.
+ |
+
<E extends Enum<E>> |
+optEnum(Class<E> clazz,
+ int index)
+Get the enum value associated with a key.
+ |
+
<E extends Enum<E>> |
+optEnum(Class<E> clazz,
+ int index,
+ E defaultValue)
+Get the enum value associated with a key.
+ |
+
float |
+optFloat(int index)
+Get the optional float value associated with an index.
+ |
+
float |
+optFloat(int index,
+ float defaultValue)
+Get the optional float value associated with an index.
+ |
+
int |
+optInt(int index)
+Get the optional int value associated with an index.
+ |
+
int |
+optInt(int index,
+ int defaultValue)
+Get the optional int value associated with an index.
+ |
+
JSONArray |
+optJSONArray(int index)
+Get the optional JSONArray associated with an index.
+ |
+
JSONObject |
+optJSONObject(int index)
+Get the optional JSONObject associated with an index.
+ |
+
long |
+optLong(int index)
+Get the optional long value associated with an index.
+ |
+
long |
+optLong(int index,
+ long defaultValue)
+Get the optional long value associated with an index.
+ |
+
Number |
+optNumber(int index)
+Get an optional
+Number value associated with a key, or null
+ if there is no such key or if the value is not a number. |
+
Number |
+optNumber(int index,
+ Number defaultValue)
+Get an optional
+Number value associated with a key, or the default if there
+ is no such key or if the value is not a number. |
+
Object |
+optQuery(JSONPointer jsonPointer)
+Queries and returns a value from this object using
+jsonPointer, or
+ returns null if the query fails due to a missing key. |
+
Object |
+optQuery(String jsonPointer)
+Queries and returns a value from this object using
+jsonPointer, or
+ returns null if the query fails due to a missing key. |
+
String |
+optString(int index)
+Get the optional string value associated with an index.
+ |
+
String |
+optString(int index,
+ String defaultValue)
+Get the optional string associated with an index.
+ |
+
JSONArray |
+put(boolean value)
+Append a boolean value.
+ |
+
JSONArray |
+put(Collection<?> value)
+Put a value in the JSONArray, where the value will be a JSONArray which
+ is produced from a Collection.
+ |
+
JSONArray |
+put(double value)
+Append a double value.
+ |
+
JSONArray |
+put(float value)
+Append a float value.
+ |
+
JSONArray |
+put(int value)
+Append an int value.
+ |
+
JSONArray |
+put(int index,
+ boolean value)
+Put or replace a boolean value in the JSONArray.
+ |
+
JSONArray |
+put(int index,
+ Collection<?> value)
+Put a value in the JSONArray, where the value will be a JSONArray which
+ is produced from a Collection.
+ |
+
JSONArray |
+put(int index,
+ double value)
+Put or replace a double value.
+ |
+
JSONArray |
+put(int index,
+ float value)
+Put or replace a float value.
+ |
+
JSONArray |
+put(int index,
+ int value)
+Put or replace an int value.
+ |
+
JSONArray |
+put(int index,
+ long value)
+Put or replace a long value.
+ |
+
JSONArray |
+put(int index,
+ Map<?,?> value)
+Put a value in the JSONArray, where the value will be a JSONObject that
+ is produced from a Map.
+ |
+
JSONArray |
+put(int index,
+ Object value)
+Put or replace an object value in the JSONArray.
+ |
+
JSONArray |
+put(long value)
+Append an long value.
+ |
+
JSONArray |
+put(Map<?,?> value)
+Put a value in the JSONArray, where the value will be a JSONObject which
+ is produced from a Map.
+ |
+
JSONArray |
+put(Object value)
+Append an object value.
+ |
+
JSONArray |
+putAll(Collection<?> collection)
+Put a collection's elements in to the JSONArray.
+ |
+
JSONArray |
+putAll(Iterable<?> iter)
+Put an Iterable's elements in to the JSONArray.
+ |
+
JSONArray |
+putAll(JSONArray array)
+Put a JSONArray's elements in to the JSONArray.
+ |
+
JSONArray |
+putAll(Object array)
+Put an array's elements in to the JSONArray.
+ |
+
Object |
+query(JSONPointer jsonPointer)
+Uses a user initialized JSONPointer and tries to
+ match it to an item within this JSONArray.
+ |
+
Object |
+query(String jsonPointer)
+Creates a JSONPointer using an initialization string and tries to
+ match it to an item within this JSONArray.
+ |
+
Object |
+remove(int index)
+Remove an index and close the hole.
+ |
+
boolean |
+similar(Object other)
+Determine if two JSONArrays are similar.
+ |
+
JSONObject |
+toJSONObject(JSONArray names)
+Produce a JSONObject by combining a JSONArray of names with the values of
+ this JSONArray.
+ |
+
List<Object> |
+toList()
+Returns a java.util.List containing all of the elements in this array.
+ |
+
String |
+toString()
+Make a JSON text of this JSONArray.
+ |
+
String |
+toString(int indentFactor)
+Make a pretty-printed JSON text of this JSONArray.
+ |
+
Writer |
+write(Writer writer)
+Write the contents of the JSONArray as JSON text to a writer.
+ |
+
Writer |
+write(Writer writer,
+ int indentFactor,
+ int indent)
+Write the contents of the JSONArray as JSON text to a writer.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic JSONArray()+
public JSONArray(JSONTokener x) + throws JSONException+
x - A JSONTokenerJSONException - If there is a syntax error.public JSONArray(String source) + throws JSONException+
source - A string that begins with [ (left
+ bracket) and ends with ]
+ (right bracket).JSONException - If there is a syntax error.public JSONArray(Collection<?> collection)+
collection - A Collection.public JSONArray(Iterable<?> iter)+
iter - A Iterable collection.public JSONArray(JSONArray array)+
array - A array.public JSONArray(Object array) + throws JSONException+
array - Array. If the parameter passed is null, or not an array, an
+ exception will be thrown.JSONException - If not an array or if an array value is non-finite number.NullPointerException - Thrown if the array parameter is null.public JSONArray(int initialCapacity) + throws JSONException+
initialCapacity - the initial capacity of the JSONArray.JSONException - If the initial capacity is negative.public Object get(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index.public boolean getBoolean(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index or if the value is not
+ convertible to boolean.public double getDouble(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
+ to a number.public float getFloat(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - if the key is not found or if the value is not a Number
+ object and cannot be converted to a number.public Number getNumber(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - if the key is not found or if the value is not a Number
+ object and cannot be converted to a number.public <E extends Enum<E>> E getEnum(Class<E> clazz, + int index) + throws JSONException+
E - Enum Typeclazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.JSONException - if the key is not found or if the value cannot be converted
+ to an enum.public BigDecimal getBigDecimal(int index) + throws JSONException+
BigDecimal.BigDecimal(double) constructor
+ will be used. See notes on the constructor for conversion issues that
+ may arise.index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
+ to a BigDecimal.public BigInteger getBigInteger(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
+ to a BigInteger.public int getInt(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value is not a number.public JSONArray getJSONArray(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If there is no value for the index. or if the value is not a
+ JSONArraypublic JSONObject getJSONObject(int index) + throws JSONException+
index - subscriptJSONException - If there is no value for the index or if the value is not a
+ JSONObjectpublic long getLong(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If the key is not found or if the value cannot be converted
+ to a number.public String getString(int index) + throws JSONException+
index - The index must be between 0 and length() - 1.JSONException - If there is no string value for the index.public boolean isNull(int index)+
null.index - The index must be between 0 and length() - 1.null, or if there is no value.public String join(String separator) + throws JSONException+
separator string is inserted between each element. Warning:
+ This method assumes that the data structure is acyclical.separator - A string that will be inserted between the elements.JSONException - If the array contains an invalid number.public int length()+
public Object opt(int index)+
index - The index must be between 0 and length() - 1. If not, null is returned.public boolean optBoolean(int index)+
index - The index must be between 0 and length() - 1.public boolean optBoolean(int index, + boolean defaultValue)+
index - The index must be between 0 and length() - 1.defaultValue - A boolean default.public double optDouble(int index)+
index - The index must be between 0 and length() - 1.public double optDouble(int index, + double defaultValue)+
index - subscriptdefaultValue - The default value.public float optFloat(int index)+
index - The index must be between 0 and length() - 1.public float optFloat(int index, + float defaultValue)+
index - subscriptdefaultValue - The default value.public int optInt(int index)+
index - The index must be between 0 and length() - 1.public int optInt(int index, + int defaultValue)+
index - The index must be between 0 and length() - 1.defaultValue - The default value.public <E extends Enum<E>> E optEnum(Class<E> clazz, + int index)+
E - Enum Typeclazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.public <E extends Enum<E>> E optEnum(Class<E> clazz, + int index, + E defaultValue)+
E - Enum Typeclazz - The type of enum to retrieve.index - The index must be between 0 and length() - 1.defaultValue - The default in case the value is not foundpublic BigInteger optBigInteger(int index, + BigInteger defaultValue)+
index - The index must be between 0 and length() - 1.defaultValue - The default value.public BigDecimal optBigDecimal(int index, + BigDecimal defaultValue)+
BigDecimal.BigDecimal(double)
+ constructor will be used. See notes on the constructor for conversion
+ issues that may arise.index - The index must be between 0 and length() - 1.defaultValue - The default value.public JSONArray optJSONArray(int index)+
index - subscriptpublic JSONObject optJSONObject(int index)+
index - The index must be between 0 and length() - 1.public long optLong(int index)+
index - The index must be between 0 and length() - 1.public long optLong(int index, + long defaultValue)+
index - The index must be between 0 and length() - 1.defaultValue - The default value.public Number optNumber(int index)+
Number value associated with a key, or null
+ if there is no such key or if the value is not a number. If the value is a string,
+ an attempt will be made to evaluate it as a number (BigDecimal). This method
+ would be used in cases where type coercion of the number value is unwanted.index - The index must be between 0 and length() - 1.public Number optNumber(int index, + Number defaultValue)+
Number value associated with a key, or the default if there
+ is no such key or if the value is not a number. If the value is a string,
+ an attempt will be made to evaluate it as a number (BigDecimal). This method
+ would be used in cases where type coercion of the number value is unwanted.index - The index must be between 0 and length() - 1.defaultValue - The default.public String optString(int index)+
index - The index must be between 0 and length() - 1.public String optString(int index, + String defaultValue)+
index - The index must be between 0 and length() - 1.defaultValue - The default value.public JSONArray put(boolean value)+
value - A boolean value.public JSONArray put(Collection<?> value)+
value - A Collection value.JSONException - If the value is non-finite number.public JSONArray put(double value) + throws JSONException+
value - A double value.JSONException - if the value is not finite.public JSONArray put(float value) + throws JSONException+
value - A float value.JSONException - if the value is not finite.public JSONArray put(int value)+
value - An int value.public JSONArray put(long value)+
value - A long value.public JSONArray put(Map<?,?> value)+
value - A Map value.JSONException - If a value in the map is non-finite number.NullPointerException - If a key in the map is nullpublic JSONArray put(Object value)+
value - An object value. The value should be a Boolean, Double,
+ Integer, JSONArray, JSONObject, Long, or String, or the
+ JSONObject.NULL object.JSONException - If the value is non-finite number.public JSONArray put(int index, + boolean value) + throws JSONException+
index - The subscript.value - A boolean value.JSONException - If the index is negative.public JSONArray put(int index, + Collection<?> value) + throws JSONException+
index - The subscript.value - A Collection value.JSONException - If the index is negative or if the value is non-finite.public JSONArray put(int index, + double value) + throws JSONException+
index - The subscript.value - A double value.JSONException - If the index is negative or if the value is non-finite.public JSONArray put(int index, + float value) + throws JSONException+
index - The subscript.value - A float value.JSONException - If the index is negative or if the value is non-finite.public JSONArray put(int index, + int value) + throws JSONException+
index - The subscript.value - An int value.JSONException - If the index is negative.public JSONArray put(int index, + long value) + throws JSONException+
index - The subscript.value - A long value.JSONException - If the index is negative.public JSONArray put(int index, + Map<?,?> value) + throws JSONException+
index - The subscript.value - The Map value.JSONException - If the index is negative or if the the value is an invalid
+ number.NullPointerException - If a key in the map is nullpublic JSONArray put(int index, + Object value) + throws JSONException+
index - The subscript.value - The value to put into the array. The value should be a
+ Boolean, Double, Integer, JSONArray, JSONObject, Long, or
+ String, or the JSONObject.NULL object.JSONException - If the index is negative or if the the value is an invalid
+ number.public JSONArray putAll(Collection<?> collection)+
collection - A Collection.public JSONArray putAll(Iterable<?> iter)+
iter - An Iterable.public JSONArray putAll(JSONArray array)+
array - A JSONArray.public JSONArray putAll(Object array) + throws JSONException+
array - Array. If the parameter passed is null, or not an array or Iterable, an
+ exception will be thrown.JSONException - If not an array, JSONArray, Iterable or if an value is non-finite number.NullPointerException - Thrown if the array parameter is null.public Object query(String jsonPointer)+
+ [
+ {"b":"c"}
+ ]
+
+ and this JSONPointer string:
+ + "/0/b" ++ Then this method will return the String "c" + A JSONPointerException may be thrown from code called by this method.
jsonPointer - string that can be used to create a JSONPointerpublic Object query(JSONPointer jsonPointer)+
+ [
+ {"b":"c"}
+ ]
+
+ and this JSONPointer:
+ + "/0/b" ++ Then this method will return the String "c" + A JSONPointerException may be thrown from code called by this method.
jsonPointer - string that can be used to create a JSONPointerpublic Object optQuery(String jsonPointer)+
jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer - the string representation of the JSON pointernullIllegalArgumentException - if jsonPointer has invalid syntaxpublic Object optQuery(JSONPointer jsonPointer)+
jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer - The JSON pointernullIllegalArgumentException - if jsonPointer has invalid syntaxpublic Object remove(int index)+
index - The index of the element to be removed.public boolean similar(Object other)+
other - The other JSONArraypublic JSONObject toJSONObject(JSONArray names) + throws JSONException+
names - A JSONArray containing a list of key strings. These will be
+ paired with the values.JSONException - If any of the names are null.public String toString()+
+ Warning: This method assumes that the data structure is acyclical. +
public String toString(int indentFactor) + throws JSONException+
If
indentFactor > 0 and the JSONArray has only
+ one element, then the array will be output on a single line:
+ [1]
+
+ If an array has 2 or more elements, then it will be output across + multiple lines:
+ [
+ 1,
+ "value 2",
+ 3
+ ]
+
+ + Warning: This method assumes that the data structure is acyclical. +
indentFactor - The number of spaces to add to each level of indentation.[ (left
+ bracket) and ending with ]
+ (right bracket).JSONException - if a called function failspublic Writer write(Writer writer) + throws JSONException+
+ Warning: This method assumes that the data structure is acyclical. +
writer - the writer objectJSONException - if a called function failspublic Writer write(Writer writer, + int indentFactor, + int indent) + throws JSONException+
If
indentFactor > 0 and the JSONArray has only
+ one element, then the array will be output on a single line:
+ [1]
+
+ If an array has 2 or more elements, then it will be output across + multiple lines:
+ [
+ 1,
+ "value 2",
+ 3
+ ]
+
+ + Warning: This method assumes that the data structure is acyclical. +
writer - Writes the serialized JSONindentFactor - The number of spaces to add to each level of indentation.indent - The indentation of the top level.JSONException - if a called function fails or unable to writepublic List<Object> toList()+
+ Warning: This method assumes that the data structure is acyclical.
public boolean isEmpty()+
public class JSONException
-extends java.lang.RuntimeException
-| Constructor and Description | -
|---|
JSONException(java.lang.String message)
-Constructs a JSONException with an explanatory message.
- |
-
JSONException(java.lang.String message,
- java.lang.Throwable cause)
-Constructs a JSONException with an explanatory message and cause.
- |
-
JSONException(java.lang.Throwable cause)
-Constructs a new JSONException with the specified cause.
- |
-
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic JSONException(java.lang.String message)-
message - Detail about the reason for the exception.public JSONException(java.lang.String message, - java.lang.Throwable cause)-
message - Detail about the reason for the exception.cause - The cause.public JSONException(java.lang.Throwable cause)-
cause - The cause.Copyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONException +extends RuntimeException+
| Constructor and Description | +
|---|
JSONException(String message)
+Constructs a JSONException with an explanatory message.
+ |
+
JSONException(String message,
+ Throwable cause)
+Constructs a JSONException with an explanatory message and cause.
+ |
+
JSONException(Throwable cause)
+Constructs a new JSONException with the specified cause.
+ |
+
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic JSONException(String message)+
message - Detail about the reason for the exception.public JSONException(String message, + Throwable cause)+
message - Detail about the reason for the exception.cause - The cause.public JSONException(Throwable cause)+
cause - The cause.public class JSONML
-extends java.lang.Object
-| Modifier and Type | -Method and Description | -
|---|---|
static JSONArray |
-toJSONArray(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
static JSONArray |
-toJSONArray(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
static JSONObject |
-toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
static JSONObject |
-toJSONObject(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
static java.lang.String |
-toString(JSONArray ja)
-Reverse the JSONML transformation, making an XML text from a JSONArray.
- |
-
static java.lang.String |
-toString(JSONObject jo)
-Reverse the JSONML transformation, making an XML text from a JSONObject.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static JSONArray toJSONArray(java.lang.String string) - throws JSONException-
<[ [ ]]> are ignored.string - The source string.JSONExceptionpublic static JSONArray toJSONArray(XMLTokener x) - throws JSONException-
<[ [ ]]> are ignored.x - An XMLTokener.JSONExceptionpublic static JSONObject toJSONObject(XMLTokener x) - throws JSONException-
<[ [ ]]> are ignored.x - An XMLTokener of the XML source text.JSONExceptionpublic static JSONObject toJSONObject(java.lang.String string) - throws JSONException-
<[ [ ]]> are ignored.string - The XML source text.JSONExceptionpublic static java.lang.String toString(JSONArray ja) - throws JSONException-
ja - A JSONArray.JSONExceptionpublic static java.lang.String toString(JSONObject jo) - throws JSONException-
jo - A JSONObject.JSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONML +extends Object+
| Modifier and Type | +Method and Description | +
|---|---|
static JSONArray |
+toJSONArray(String string)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONArray using the JsonML transform.
+ |
+
static JSONArray |
+toJSONArray(String string,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONArray using the JsonML transform.
+ |
+
static JSONArray |
+toJSONArray(XMLTokener x)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONArray using the JsonML transform.
+ |
+
static JSONArray |
+toJSONArray(XMLTokener x,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONArray using the JsonML transform.
+ |
+
static JSONObject |
+toJSONObject(String string)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject using the JsonML transform.
+ |
+
static JSONObject |
+toJSONObject(String string,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject using the JsonML transform.
+ |
+
static JSONObject |
+toJSONObject(XMLTokener x)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject using the JsonML transform.
+ |
+
static JSONObject |
+toJSONObject(XMLTokener x,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject using the JsonML transform.
+ |
+
static String |
+toString(JSONArray ja)
+Reverse the JSONML transformation, making an XML text from a JSONArray.
+ |
+
static String |
+toString(JSONObject jo)
+Reverse the JSONML transformation, making an XML text from a JSONObject.
+ |
+
public static JSONArray toJSONArray(String string) + throws JSONException+
<[ [ ]]> are ignored.string - The source string.JSONException - Thrown on error converting to a JSONArraypublic static JSONArray toJSONArray(String string, + boolean keepStrings) + throws JSONException+
<[ [ ]]> are ignored.string - The source string.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown on error converting to a JSONArraypublic static JSONArray toJSONArray(XMLTokener x, + boolean keepStrings) + throws JSONException+
<[ [ ]]> are ignored.x - An XMLTokener.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown on error converting to a JSONArraypublic static JSONArray toJSONArray(XMLTokener x) + throws JSONException+
<[ [ ]]> are ignored.x - An XMLTokener.JSONException - Thrown on error converting to a JSONArraypublic static JSONObject toJSONObject(String string) + throws JSONException+
<[ [ ]]> are ignored.string - The XML source text.JSONException - Thrown on error converting to a JSONObjectpublic static JSONObject toJSONObject(String string, + boolean keepStrings) + throws JSONException+
<[ [ ]]> are ignored.string - The XML source text.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown on error converting to a JSONObjectpublic static JSONObject toJSONObject(XMLTokener x) + throws JSONException+
<[ [ ]]> are ignored.x - An XMLTokener of the XML source text.JSONException - Thrown on error converting to a JSONObjectpublic static JSONObject toJSONObject(XMLTokener x, + boolean keepStrings) + throws JSONException+
<[ [ ]]> are ignored.x - An XMLTokener of the XML source text.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown on error converting to a JSONObjectpublic static String toString(JSONArray ja) + throws JSONException+
ja - A JSONArray.JSONException - Thrown on error converting to a stringpublic static String toString(JSONObject jo) + throws JSONException+
jo - A JSONObject.JSONException - Thrown on error converting to a stringpublic class JSONObject +extends Object+
get and opt methods for accessing
+ the values by name, and put methods for adding or replacing
+ values by name. The values can be any of these types: Boolean,
+ JSONArray, JSONObject, Number,
+ String, or the JSONObject.NULL object. A
+ JSONObject constructor can be used to convert an external form JSON text
+ into an internal form whose values can be retrieved with the
+ get and opt methods, or to convert values into a
+ JSON text using the put and toString methods. A
+ get method returns a value if one can be found, and throws an
+ exception if one cannot be found. An opt method returns a
+ default value instead of throwing an exception, and so is useful for
+ obtaining optional values.
+
+ The generic get() and opt() methods return an
+ object, which you can cast or query for type. There are also typed
+ get and opt methods that do type checking and type
+ coercion for you. The opt methods differ from the get methods in that they
+ do not throw. Instead, they return a specified value, such as null.
+
+ The put methods add or replace values in an object. For
+ example,
+
+
+ myString = new JSONObject()
+ .put("JSON", "Hello, World!").toString();
+
+
+ produces the string {"JSON": "Hello, World"}.
+
+ The texts produced by the toString methods strictly conform to
+ the JSON syntax rules. The constructors are more forgiving in the texts they
+ will accept:
+
, (comma) may appear just
+ before the closing brace.' (single
+ quote).{ } [ ] / \ : , # and if they do not look like numbers and
+ if they are not the reserved words true, false,
+ or null.| Modifier and Type | +Field and Description | +
|---|---|
static Object |
+NULL
+It is sometimes more convenient and less ambiguous to have a
+
+NULL object than to use Java's null value. |
+
| Modifier | +Constructor and Description | +
|---|---|
|
+JSONObject()
+Construct an empty JSONObject.
+ |
+
protected |
+JSONObject(int initialCapacity)
+Constructor to specify an initial capacity of the internal map.
+ |
+
|
+JSONObject(JSONObject jo,
+ String... names)
+Construct a JSONObject from a subset of another JSONObject.
+ |
+
|
+JSONObject(JSONTokener x)
+Construct a JSONObject from a JSONTokener.
+ |
+
|
+JSONObject(Map<?,?> m)
+Construct a JSONObject from a Map.
+ |
+
|
+JSONObject(Object bean)
+Construct a JSONObject from an Object using bean getters.
+ |
+
|
+JSONObject(Object object,
+ String... names)
+Construct a JSONObject from an Object, using reflection to find the
+ public members.
+ |
+
|
+JSONObject(String source)
+Construct a JSONObject from a source JSON text string.
+ |
+
|
+JSONObject(String baseName,
+ Locale locale)
+Construct a JSONObject from a ResourceBundle.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
JSONObject |
+accumulate(String key,
+ Object value)
+Accumulate values under a key.
+ |
+
JSONObject |
+append(String key,
+ Object value)
+Append values to the array under a key.
+ |
+
static String |
+doubleToString(double d)
+Produce a string from a double.
+ |
+
protected Set<Map.Entry<String,Object>> |
+entrySet()
+Get a set of entries of the JSONObject.
+ |
+
Object |
+get(String key)
+Get the value object associated with a key.
+ |
+
BigDecimal |
+getBigDecimal(String key)
+Get the BigDecimal value associated with a key.
+ |
+
BigInteger |
+getBigInteger(String key)
+Get the BigInteger value associated with a key.
+ |
+
boolean |
+getBoolean(String key)
+Get the boolean value associated with a key.
+ |
+
double |
+getDouble(String key)
+Get the double value associated with a key.
+ |
+
<E extends Enum<E>> |
+getEnum(Class<E> clazz,
+ String key)
+Get the enum value associated with a key.
+ |
+
float |
+getFloat(String key)
+Get the float value associated with a key.
+ |
+
int |
+getInt(String key)
+Get the int value associated with a key.
+ |
+
JSONArray |
+getJSONArray(String key)
+Get the JSONArray value associated with a key.
+ |
+
JSONObject |
+getJSONObject(String key)
+Get the JSONObject value associated with a key.
+ |
+
long |
+getLong(String key)
+Get the long value associated with a key.
+ |
+
static String[] |
+getNames(JSONObject jo)
+Get an array of field names from a JSONObject.
+ |
+
static String[] |
+getNames(Object object)
+Get an array of public field names from an Object.
+ |
+
Number |
+getNumber(String key)
+Get the Number value associated with a key.
+ |
+
String |
+getString(String key)
+Get the string associated with a key.
+ |
+
boolean |
+has(String key)
+Determine if the JSONObject contains a specific key.
+ |
+
JSONObject |
+increment(String key)
+Increment a property of a JSONObject.
+ |
+
protected static boolean |
+isDecimalNotation(String val)
+Tests if the value should be tried as a decimal.
+ |
+
boolean |
+isEmpty()
+Check if JSONObject is empty.
+ |
+
boolean |
+isNull(String key)
+Determine if the value associated with the key is
+null or if there is no
+ value. |
+
Iterator<String> |
+keys()
+Get an enumeration of the keys of the JSONObject.
+ |
+
Set<String> |
+keySet()
+Get a set of keys of the JSONObject.
+ |
+
int |
+length()
+Get the number of keys stored in the JSONObject.
+ |
+
JSONArray |
+names()
+Produce a JSONArray containing the names of the elements of this
+ JSONObject.
+ |
+
static String |
+numberToString(Number number)
+Produce a string from a Number.
+ |
+
Object |
+opt(String key)
+Get an optional value associated with a key.
+ |
+
BigDecimal |
+optBigDecimal(String key,
+ BigDecimal defaultValue)
+Get an optional BigDecimal associated with a key, or the defaultValue if
+ there is no such key or if its value is not a number.
+ |
+
BigInteger |
+optBigInteger(String key,
+ BigInteger defaultValue)
+Get an optional BigInteger associated with a key, or the defaultValue if
+ there is no such key or if its value is not a number.
+ |
+
boolean |
+optBoolean(String key)
+Get an optional boolean associated with a key.
+ |
+
boolean |
+optBoolean(String key,
+ boolean defaultValue)
+Get an optional boolean associated with a key.
+ |
+
double |
+optDouble(String key)
+Get an optional double associated with a key, or NaN if there is no such
+ key or if its value is not a number.
+ |
+
double |
+optDouble(String key,
+ double defaultValue)
+Get an optional double associated with a key, or the defaultValue if
+ there is no such key or if its value is not a number.
+ |
+
<E extends Enum<E>> |
+optEnum(Class<E> clazz,
+ String key)
+Get the enum value associated with a key.
+ |
+
<E extends Enum<E>> |
+optEnum(Class<E> clazz,
+ String key,
+ E defaultValue)
+Get the enum value associated with a key.
+ |
+
float |
+optFloat(String key)
+Get the optional double value associated with an index.
+ |
+
float |
+optFloat(String key,
+ float defaultValue)
+Get the optional double value associated with an index.
+ |
+
int |
+optInt(String key)
+Get an optional int value associated with a key, or zero if there is no
+ such key or if the value is not a number.
+ |
+
int |
+optInt(String key,
+ int defaultValue)
+Get an optional int value associated with a key, or the default if there
+ is no such key or if the value is not a number.
+ |
+
JSONArray |
+optJSONArray(String key)
+Get an optional JSONArray associated with a key.
+ |
+
JSONObject |
+optJSONObject(String key)
+Get an optional JSONObject associated with a key.
+ |
+
long |
+optLong(String key)
+Get an optional long value associated with a key, or zero if there is no
+ such key or if the value is not a number.
+ |
+
long |
+optLong(String key,
+ long defaultValue)
+Get an optional long value associated with a key, or the default if there
+ is no such key or if the value is not a number.
+ |
+
Number |
+optNumber(String key)
+Get an optional
+Number value associated with a key, or null
+ if there is no such key or if the value is not a number. |
+
Number |
+optNumber(String key,
+ Number defaultValue)
+Get an optional
+Number value associated with a key, or the default if there
+ is no such key or if the value is not a number. |
+
Object |
+optQuery(JSONPointer jsonPointer)
+Queries and returns a value from this object using
+jsonPointer, or
+ returns null if the query fails due to a missing key. |
+
Object |
+optQuery(String jsonPointer)
+Queries and returns a value from this object using
+jsonPointer, or
+ returns null if the query fails due to a missing key. |
+
String |
+optString(String key)
+Get an optional string associated with a key.
+ |
+
String |
+optString(String key,
+ String defaultValue)
+Get an optional string associated with a key.
+ |
+
JSONObject |
+put(String key,
+ boolean value)
+Put a key/boolean pair in the JSONObject.
+ |
+
JSONObject |
+put(String key,
+ Collection<?> value)
+Put a key/value pair in the JSONObject, where the value will be a
+ JSONArray which is produced from a Collection.
+ |
+
JSONObject |
+put(String key,
+ double value)
+Put a key/double pair in the JSONObject.
+ |
+
JSONObject |
+put(String key,
+ float value)
+Put a key/float pair in the JSONObject.
+ |
+
JSONObject |
+put(String key,
+ int value)
+Put a key/int pair in the JSONObject.
+ |
+
JSONObject |
+put(String key,
+ long value)
+Put a key/long pair in the JSONObject.
+ |
+
JSONObject |
+put(String key,
+ Map<?,?> value)
+Put a key/value pair in the JSONObject, where the value will be a
+ JSONObject which is produced from a Map.
+ |
+
JSONObject |
+put(String key,
+ Object value)
+Put a key/value pair in the JSONObject.
+ |
+
JSONObject |
+putOnce(String key,
+ Object value)
+Put a key/value pair in the JSONObject, but only if the key and the value
+ are both non-null, and only if there is not already a member with that
+ name.
+ |
+
JSONObject |
+putOpt(String key,
+ Object value)
+Put a key/value pair in the JSONObject, but only if the key and the value
+ are both non-null.
+ |
+
Object |
+query(JSONPointer jsonPointer)
+Uses a user initialized JSONPointer and tries to
+ match it to an item within this JSONObject.
+ |
+
Object |
+query(String jsonPointer)
+Creates a JSONPointer using an initialization string and tries to
+ match it to an item within this JSONObject.
+ |
+
static String |
+quote(String string)
+Produce a string in double quotes with backslash sequences in all the
+ right places.
+ |
+
static Writer |
+quote(String string,
+ Writer w) |
+
Object |
+remove(String key)
+Remove a name and its value, if present.
+ |
+
boolean |
+similar(Object other)
+Determine if two JSONObjects are similar.
+ |
+
protected static Number |
+stringToNumber(String val)
+Converts a string to a number using the narrowest possible type.
+ |
+
static Object |
+stringToValue(String string)
+Try to convert a string into a number, boolean, or null.
+ |
+
static void |
+testValidity(Object o)
+Throw an exception if the object is a NaN or infinite number.
+ |
+
JSONArray |
+toJSONArray(JSONArray names)
+Produce a JSONArray containing the values of the members of this
+ JSONObject.
+ |
+
Map<String,Object> |
+toMap()
+Returns a java.util.Map containing all of the entries in this object.
+ |
+
String |
+toString()
+Make a JSON text of this JSONObject.
+ |
+
String |
+toString(int indentFactor)
+Make a pretty-printed JSON text of this JSONObject.
+ |
+
static String |
+valueToString(Object value)
+Make a JSON text of an Object value.
+ |
+
static Object |
+wrap(Object object)
+Wrap an object, if necessary.
+ |
+
Writer |
+write(Writer writer)
+Write the contents of the JSONObject as JSON text to a writer.
+ |
+
Writer |
+write(Writer writer,
+ int indentFactor,
+ int indent)
+Write the contents of the JSONObject as JSON text to a writer.
+ |
+
public static final Object NULL+
NULL object than to use Java's null value.
+ JSONObject.NULL.equals(null) returns true.
+ JSONObject.NULL.toString() returns "null".public JSONObject()+
public JSONObject(JSONObject jo, + String... names)+
jo - A JSONObject.names - An array of strings.public JSONObject(JSONTokener x) + throws JSONException+
x - A JSONTokener object containing the source string.JSONException - If there is a syntax error in the source string or a
+ duplicated key.public JSONObject(Map<?,?> m)+
m - A map object that can be used to initialize the contents of
+ the JSONObject.JSONException - If a value in the map is non-finite number.NullPointerException - If a key in the map is nullpublic JSONObject(Object bean)+
"get" or
+ "is" followed by an uppercase letter, the method is invoked,
+ and a key and the value returned from the getter method are put into the
+ new JSONObject.
+
+ The key is formed by removing the "get" or "is"
+ prefix. If the second remaining character is not upper case, then the
+ first character is converted to lower case.
+
+ Methods that are static, return void,
+ have parameters, or are "bridge" methods, are ignored.
+
+ For example, if an object has a method named "getName", and
+ if the result of calling object.getName() is
+ "Larry Fine", then the JSONObject will contain
+ "name": "Larry Fine".
+
+ The JSONPropertyName annotation can be used on a bean getter to
+ override key name used in the JSONObject. For example, using the object
+ above with the getName method, if we annotated it with:
+
+ @JSONPropertyName("FullName")
+ public String getName() { return this.name; }
+
+ The resulting JSON object would contain "FullName": "Larry Fine"
+
+ Similarly, the JSONPropertyName annotation can be used on non-
+ get and is methods. We can also override key
+ name used in the JSONObject as seen below even though the field would normally
+ be ignored:
+
+ @JSONPropertyName("FullName")
+ public String fullName() { return this.name; }
+
+ The resulting JSON object would contain "FullName": "Larry Fine"
+
+ The JSONPropertyIgnore annotation can be used to force the bean property
+ to not be serialized into JSON. If both JSONPropertyIgnore and
+ JSONPropertyName are defined on the same method, a depth comparison is
+ performed and the one closest to the concrete class being serialized is used.
+ If both annotations are at the same level, then the JSONPropertyIgnore
+ annotation takes precedent and the field is not serialized.
+ For example, the following declaration would prevent the getName
+ method from being serialized:
+
+ @JSONPropertyName("FullName")
+ @JSONPropertyIgnore
+ public String getName() { return this.name; }
+
+ bean - An object that has getter methods that should be used to make
+ a JSONObject.public JSONObject(Object object, + String... names)+
object - An object that has fields that should be used to make a
+ JSONObject.names - An array of strings, the names of the fields to be obtained
+ from the object.public JSONObject(String source) + throws JSONException+
source - A string beginning with { (left
+ brace) and ending with }
+ (right brace).JSONException - If there is a syntax error in the source string or a
+ duplicated key.public JSONObject(String baseName, + Locale locale) + throws JSONException+
baseName - The ResourceBundle base name.locale - The Locale to load the ResourceBundle for.JSONException - If any JSONExceptions are detected.protected JSONObject(int initialCapacity)+
initialCapacity - initial capacity of the internal map.public JSONObject accumulate(String key, + Object value) + throws JSONException+
key - A key string.value - An object to be accumulated under the key.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject append(String key, + Object value) + throws JSONException+
key - A key string.value - An object to be accumulated under the key.JSONException - If the value is non-finite number or if the current value associated with
+ the key is not a JSONArray.NullPointerException - If the key is null.public static String doubleToString(double d)+
d - A double.public Object get(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found.public <E extends Enum<E>> E getEnum(Class<E> clazz, + String key) + throws JSONException+
E - Enum Typeclazz - The type of enum to retrieve.key - A key string.JSONException - if the key is not found or if the value cannot be converted
+ to an enum.public boolean getBoolean(String key) + throws JSONException+
key - A key string.JSONException - if the value is not a Boolean or the String "true" or
+ "false".public BigInteger getBigInteger(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value cannot
+ be converted to BigInteger.public BigDecimal getBigDecimal(String key) + throws JSONException+
BigDecimal.BigDecimal(double) constructor will
+ be used. See notes on the constructor for conversion issues that may
+ arise.key - A key string.JSONException - if the key is not found or if the value
+ cannot be converted to BigDecimal.public double getDouble(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value is not a Number
+ object and cannot be converted to a number.public float getFloat(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value is not a Number
+ object and cannot be converted to a number.public Number getNumber(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value is not a Number
+ object and cannot be converted to a number.public int getInt(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value cannot be converted
+ to an integer.public JSONArray getJSONArray(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value is not a JSONArray.public JSONObject getJSONObject(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value is not a JSONObject.public long getLong(String key) + throws JSONException+
key - A key string.JSONException - if the key is not found or if the value cannot be converted
+ to a long.public static String[] getNames(JSONObject jo)+
jo - JSON objectpublic static String[] getNames(Object object)+
object - object to readpublic String getString(String key) + throws JSONException+
key - A key string.JSONException - if there is no string value for the key.public boolean has(String key)+
key - A key string.public JSONObject increment(String key) + throws JSONException+
key - A key string.JSONException - If there is already a property with this name that is not an
+ Integer, Long, Double, or Float.public boolean isNull(String key)+
null or if there is no
+ value.key - A key string.public Iterator<String> keys()+
Set.iterator()public Set<String> keySet()+
Map.keySet()protected Set<Map.Entry<String,Object>> entrySet()+
Map.entrySet()public int length()+
public boolean isEmpty()+
public JSONArray names()+
public static String numberToString(Number number) + throws JSONException+
number - A NumberJSONException - If n is a non-finite number.public Object opt(String key)+
key - A key string.public <E extends Enum<E>> E optEnum(Class<E> clazz, + String key)+
E - Enum Typeclazz - The type of enum to retrieve.key - A key string.public <E extends Enum<E>> E optEnum(Class<E> clazz, + String key, + E defaultValue)+
E - Enum Typeclazz - The type of enum to retrieve.key - A key string.defaultValue - The default in case the value is not foundclazzpublic boolean optBoolean(String key)+
key - A key string.public boolean optBoolean(String key, + boolean defaultValue)+
key - A key string.defaultValue - The default.public BigDecimal optBigDecimal(String key, + BigDecimal defaultValue)+
BigDecimal.BigDecimal(double)
+ constructor will be used. See notes on the constructor for conversion
+ issues that may arise.key - A key string.defaultValue - The default.public BigInteger optBigInteger(String key, + BigInteger defaultValue)+
key - A key string.defaultValue - The default.public double optDouble(String key)+
key - A string which is the key.public double optDouble(String key, + double defaultValue)+
key - A key string.defaultValue - The default.public float optFloat(String key)+
key - A key string.public float optFloat(String key, + float defaultValue)+
key - A key string.defaultValue - The default value.public int optInt(String key)+
key - A key string.public int optInt(String key, + int defaultValue)+
key - A key string.defaultValue - The default.public JSONArray optJSONArray(String key)+
key - A key string.public JSONObject optJSONObject(String key)+
key - A key string.public long optLong(String key)+
key - A key string.public long optLong(String key, + long defaultValue)+
key - A key string.defaultValue - The default.public Number optNumber(String key)+
Number value associated with a key, or null
+ if there is no such key or if the value is not a number. If the value is a string,
+ an attempt will be made to evaluate it as a number (BigDecimal). This method
+ would be used in cases where type coercion of the number value is unwanted.key - A key string.public Number optNumber(String key, + Number defaultValue)+
Number value associated with a key, or the default if there
+ is no such key or if the value is not a number. If the value is a string,
+ an attempt will be made to evaluate it as a number. This method
+ would be used in cases where type coercion of the number value is unwanted.key - A key string.defaultValue - The default.public String optString(String key)+
key - A key string.public String optString(String key, + String defaultValue)+
key - A key string.defaultValue - The default.public JSONObject put(String key, + boolean value) + throws JSONException+
key - A key string.value - A boolean which is the value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + Collection<?> value) + throws JSONException+
key - A key string.value - A Collection value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + double value) + throws JSONException+
key - A key string.value - A double which is the value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + float value) + throws JSONException+
key - A key string.value - A float which is the value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + int value) + throws JSONException+
key - A key string.value - An int which is the value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + long value) + throws JSONException+
key - A key string.value - A long which is the value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + Map<?,?> value) + throws JSONException+
key - A key string.value - A Map value.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject put(String key, + Object value) + throws JSONException+
null, then the
+ key will be removed from the JSONObject if it is present.key - A key string.value - An object which is the value. It should be of one of these
+ types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
+ String, or the JSONObject.NULL object.JSONException - If the value is non-finite number.NullPointerException - If the key is null.public JSONObject putOnce(String key, + Object value) + throws JSONException+
key - key to insert intovalue - value to insertJSONException - if the key is a duplicatepublic JSONObject putOpt(String key, + Object value) + throws JSONException+
key - A key string.value - An object which is the value. It should be of one of these
+ types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
+ String, or the JSONObject.NULL object.JSONException - If the value is a non-finite number.public Object query(String jsonPointer)+
+ {
+ "a":{"b":"c"}
+ }
+
+ and this JSONPointer string:
+ + "/a/b" ++ Then this method will return the String "c". + A JSONPointerException may be thrown from code called by this method.
jsonPointer - string that can be used to create a JSONPointerpublic Object query(JSONPointer jsonPointer)+
+ {
+ "a":{"b":"c"}
+ }
+
+ and this JSONPointer:
+ + "/a/b" ++ Then this method will return the String "c". + A JSONPointerException may be thrown from code called by this method.
jsonPointer - string that can be used to create a JSONPointerpublic Object optQuery(String jsonPointer)+
jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer - the string representation of the JSON pointernullIllegalArgumentException - if jsonPointer has invalid syntaxpublic Object optQuery(JSONPointer jsonPointer)+
jsonPointer, or
+ returns null if the query fails due to a missing key.jsonPointer - The JSON pointernullIllegalArgumentException - if jsonPointer has invalid syntaxpublic static String quote(String string)+
string - A Stringpublic static Writer quote(String string, + Writer w) + throws IOException+
IOExceptionpublic Object remove(String key)+
key - The name to be removed.public boolean similar(Object other)+
other - The other JSONObjectprotected static boolean isDecimalNotation(String val)+
val - value to testprotected static Number stringToNumber(String val) + throws NumberFormatException+
val - value to convertNumberFormatException - thrown if the value is not a valid number. A public
+ caller should catch this and wrap it in a JSONException if applicable.public static Object stringToValue(String string)+
string - A String. can not be null.NullPointerException - Thrown if the string is null.public static void testValidity(Object o) + throws JSONException+
o - The object to test.JSONException - If o is a non-finite number.public JSONArray toJSONArray(JSONArray names) + throws JSONException+
names - A JSONArray containing a list of key strings. This determines
+ the sequence of the values in the result.JSONException - If any of the values are non-finite numbers.public String toString()+
+ Warning: This method assumes that the data structure is acyclical. +
public String toString(int indentFactor) + throws JSONException+
If
indentFactor > 0 and the JSONObject
+ has only one key, then the object will be output on a single line:
+ {"key": 1}
+
+ If an object has 2 or more keys, then it will be output across + multiple lines:
{
+ "key1": 1,
+ "key2": "value 2",
+ "key3": 3
+ }
+ + Warning: This method assumes that the data structure is acyclical. +
indentFactor - The number of spaces to add to each level of indentation.{ (left
+ brace) and ending with } (right
+ brace).JSONException - If the object contains an invalid number.public static String valueToString(Object value) + throws JSONException+
+ Warning: This method assumes that the data structure is acyclical.
value - The value to be serialized.{ (left
+ brace) and ending with } (right
+ brace).JSONException - If the value is or contains an invalid number.public static Object wrap(Object object)+
null, return the NULL
+ object. If it is an array or collection, wrap it in a JSONArray. If it is
+ a map, wrap it in a JSONObject. If it is a standard property (Double,
+ String, et al) then it is already wrapped. Otherwise, if it comes from
+ one of the java packages, turn it into a string. And if it doesn't, try
+ to wrap it in a JSONObject. If the wrapping fails, then null is returned.object - The object to wrappublic Writer write(Writer writer) + throws JSONException+
+ Warning: This method assumes that the data structure is acyclical. +
writer - the writer objectJSONException - if a called function has an errorpublic Writer write(Writer writer, + int indentFactor, + int indent) + throws JSONException+
If
indentFactor > 0 and the JSONObject
+ has only one key, then the object will be output on a single line:
+ {"key": 1}
+
+ If an object has 2 or more keys, then it will be output across + multiple lines:
{
+ "key1": 1,
+ "key2": "value 2",
+ "key3": 3
+ }
+ + Warning: This method assumes that the data structure is acyclical. +
writer - Writes the serialized JSONindentFactor - The number of spaces to add to each level of indentation.indent - The indentation of the top level.JSONException - if a called function has an error or a write error
+ occurspublic Map<String,Object> toMap()+
+ Warning: This method assumes that the data structure is acyclical.
public static class JSONPointer.Builder +extends Object+
| Modifier and Type | +Method and Description | +
|---|---|
JSONPointer.Builder |
+append(int arrayIndex)
+Adds an integer to the reference token list.
+ |
+
JSONPointer.Builder |
+append(String token)
+Adds an arbitrary token to the list of reference tokens.
+ |
+
JSONPointer |
+build()
+Creates a
+JSONPointer instance using the tokens previously set using the
+ append(String) method calls. |
+
public JSONPointer build()+
JSONPointer instance using the tokens previously set using the
+ append(String) method calls.public JSONPointer.Builder append(String token)+
"a~b" then you should simply pass the "a~b" string as-is, there is no
+ need to escape it as "a~0b".token - the new token to be appended to the listthisNullPointerException - if token is nullpublic JSONPointer.Builder append(int arrayIndex)+
arrayIndex - the array index to be added to the token listthispublic class JSONPointer +extends Object+
| Modifier and Type | +Class and Description | +
|---|---|
static class |
+JSONPointer.Builder
+This class allows the user to build a JSONPointer in steps, using
+ exactly one segment in each step.
+ |
+
| Constructor and Description | +
|---|
JSONPointer(List<String> refTokens) |
+
JSONPointer(String pointer)
+Pre-parses and initializes a new
+JSONPointer instance. |
+
| Modifier and Type | +Method and Description | +
|---|---|
static JSONPointer.Builder |
+builder()
+Static factory method for
+JSONPointer.Builder. |
+
Object |
+queryFrom(Object document)
+Evaluates this JSON Pointer on the given
+document. |
+
String |
+toString()
+Returns a string representing the JSONPointer path value using string
+ representation
+ |
+
String |
+toURIFragment()
+Returns a string representing the JSONPointer path value using URI
+ fragment identifier representation
+ |
+
public JSONPointer(String pointer)+
JSONPointer instance. If you want to
+ evaluate the same JSON Pointer on different JSON documents then it is recommended
+ to keep the JSONPointer instances due to performance considerations.pointer - the JSON String or URI Fragment representation of the JSON pointer.IllegalArgumentException - if pointer is not a valid JSON pointerpublic static JSONPointer.Builder builder()+
JSONPointer.Builder. Example usage:
+
+
+ JSONPointer pointer = JSONPointer.builder()
+ .append("obj")
+ .append("other~key").append("another/key")
+ .append("\"")
+ .append(0)
+ .build();
+ JSONPointer instance by chained
+ JSONPointer.Builder.append(String) calls.public Object queryFrom(Object document) + throws JSONPointerException+
document. The document
+ is usually a JSONObject or a JSONArray instance, but the empty
+ JSON Pointer ("") can be evaluated on any JSON values and in such case the
+ returned value will be document itself.document - the JSON document which should be the subject of querying.JSONPointerException - if an error occurs during evaluationpublic String toString()+
public String toURIFragment()+
public class JSONPointerException +extends JSONException+
JSONPointer if an error occurs
+ during evaluating a pointer.| Constructor and Description | +
|---|
JSONPointerException(String message) |
+
JSONPointerException(String message,
+ Throwable cause) |
+
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString@Documented + @Retention(value=RUNTIME) + @Target(value=METHOD) +public @interface JSONPropertyIgnore+
@Documented + @Retention(value=RUNTIME) + @Target(value=METHOD) +public @interface JSONPropertyName+
public interface JSONString
-JSONString interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString(), JSONArray.toString(),
- and JSONWriter.value(Object). The
- toJSONString method will be used instead of the default behavior
- of using the Object's toString() method and quoting the result.| Modifier and Type | -Method and Description | -
|---|---|
java.lang.String |
-toJSONString()
-The
-toJSONString method allows a class to produce its own JSON
- serialization. |
-
Copyright © 2016. All Rights Reserved.
- - + + + + + +public interface JSONString
+JSONString interface allows a toJSONString()
+ method so that a class can change the behavior of
+ JSONObject.toString(), JSONArray.toString(),
+ and JSONWriter.value(Object). The
+ toJSONString method will be used instead of the default behavior
+ of using the Object's toString() method and quoting the result.| Modifier and Type | +Method and Description | +
|---|---|
String |
+toJSONString()
+The
+toJSONString method allows a class to produce its own JSON
+ serialization. |
+
public class JSONStringer -extends JSONWriter-
- A JSONStringer instance provides a value method for appending
- values to the
- text, and a key
- method for adding keys before values in objects. There are array
- and endArray methods that make and bound array values, and
- object and endObject methods which make and bound
- object values. All of these methods return the JSONWriter instance,
- permitting cascade style. For example,
- myString = new JSONStringer()
- .object()
- .key("JSON")
- .value("Hello, World!")
- .endObject()
- .toString(); which produces the string
- {"JSON":"Hello, World!"}
-
- The first method called must be array or object.
- There are no methods for adding commas or colons. JSONStringer adds them for
- you. Objects and arrays can be nested up to 20 levels deep.
-
- This can sometimes be easier than using a JSONObject to build a string.
mode, writer| Constructor and Description | -
|---|
JSONStringer()
-Make a fresh JSONStringer.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
java.lang.String |
-toString()
-Return the JSON text.
- |
-
array, endArray, endObject, key, object, value, value, value, valueclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic JSONStringer()-
public java.lang.String toString()-
null if there was a
- problem in the construction of the JSON text (such as the calls to
- array were not properly balanced with calls to
- endArray).toString in class java.lang.ObjectCopyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONStringer +extends JSONWriter+
+ A JSONStringer instance provides a value method for appending
+ values to the
+ text, and a key
+ method for adding keys before values in objects. There are array
+ and endArray methods that make and bound array values, and
+ object and endObject methods which make and bound
+ object values. All of these methods return the JSONWriter instance,
+ permitting cascade style. For example,
+ myString = new JSONStringer()
+ .object()
+ .key("JSON")
+ .value("Hello, World!")
+ .endObject()
+ .toString(); which produces the string
+ {"JSON":"Hello, World!"}
+
+ The first method called must be array or object.
+ There are no methods for adding commas or colons. JSONStringer adds them for
+ you. Objects and arrays can be nested up to 20 levels deep.
+
+ This can sometimes be easier than using a JSONObject to build a string.
mode, writer| Constructor and Description | +
|---|
JSONStringer()
+Make a fresh JSONStringer.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
String |
+toString()
+Return the JSON text.
+ |
+
public JSONStringer()+
public String toString()+
null if there was a
+ problem in the construction of the JSON text (such as the calls to
+ array were not properly balanced with calls to
+ endArray).public class JSONTokener
-extends java.lang.Object
-| Constructor and Description | -
|---|
JSONTokener(java.io.InputStream inputStream)
-Construct a JSONTokener from an InputStream.
- |
-
JSONTokener(java.io.Reader reader)
-Construct a JSONTokener from a Reader.
- |
-
JSONTokener(java.lang.String s)
-Construct a JSONTokener from a string.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
void |
-back()
-Back up one character.
- |
-
static int |
-dehexchar(char c)
-Get the hex value of a character (base16).
- |
-
boolean |
-end() |
-
boolean |
-more()
-Determine if the source string still contains characters that next()
- can consume.
- |
-
char |
-next()
-Get the next character in the source string.
- |
-
char |
-next(char c)
-Consume the next character, and check that it matches a specified
- character.
- |
-
java.lang.String |
-next(int n)
-Get the next n characters.
- |
-
char |
-nextClean()
-Get the next char in the string, skipping whitespace.
- |
-
java.lang.String |
-nextString(char quote)
-Return the characters up to the next close quote character.
- |
-
java.lang.String |
-nextTo(char delimiter)
-Get the text up but not including the specified character or the
- end of line, whichever comes first.
- |
-
java.lang.String |
-nextTo(java.lang.String delimiters)
-Get the text up but not including one of the specified delimiter
- characters or the end of line, whichever comes first.
- |
-
java.lang.Object |
-nextValue()
-Get the next value.
- |
-
char |
-skipTo(char to)
-Skip characters until the next character is the requested character.
- |
-
JSONException |
-syntaxError(java.lang.String message)
-Make a JSONException to signal a syntax error.
- |
-
java.lang.String |
-toString()
-Make a printable string of this JSONTokener.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic JSONTokener(java.io.Reader reader)-
reader - A reader.public JSONTokener(java.io.InputStream inputStream) - throws JSONException-
inputStream - The source.JSONExceptionpublic JSONTokener(java.lang.String s)-
s - A source string.public void back() - throws JSONException-
JSONExceptionpublic static int dehexchar(char c)-
c - A character between '0' and '9' or between 'A' and 'F' or
- between 'a' and 'f'.public boolean end()-
public boolean more() - throws JSONException-
JSONExceptionpublic char next() - throws JSONException-
JSONExceptionpublic char next(char c) - throws JSONException-
c - The character to match.JSONException - if the character does not match.public java.lang.String next(int n) - throws JSONException-
n - The number of characters to take.JSONException - Substring bounds error if there are not
- n characters remaining in the source string.public char nextClean() - throws JSONException-
JSONExceptionpublic java.lang.String nextString(char quote) - throws JSONException-
quote - The quoting character, either
- " (double quote) or
- ' (single quote).JSONException - Unterminated string.public java.lang.String nextTo(char delimiter) - throws JSONException-
delimiter - A delimiter character.JSONExceptionpublic java.lang.String nextTo(java.lang.String delimiters) - throws JSONException-
delimiters - A set of delimiter characters.JSONExceptionpublic java.lang.Object nextValue() - throws JSONException-
JSONException - If syntax error.public char skipTo(char to) - throws JSONException-
to - A character to skip to.JSONExceptionpublic JSONException syntaxError(java.lang.String message)-
message - The error message.public java.lang.String toString()-
toString in class java.lang.ObjectCopyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONTokener +extends Object+
| Constructor and Description | +
|---|
JSONTokener(InputStream inputStream)
+Construct a JSONTokener from an InputStream.
+ |
+
JSONTokener(Reader reader)
+Construct a JSONTokener from a Reader.
+ |
+
JSONTokener(String s)
+Construct a JSONTokener from a string.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
void |
+back()
+Back up one character.
+ |
+
static int |
+dehexchar(char c)
+Get the hex value of a character (base16).
+ |
+
boolean |
+end()
+Checks if the end of the input has been reached.
+ |
+
boolean |
+more()
+Determine if the source string still contains characters that next()
+ can consume.
+ |
+
char |
+next()
+Get the next character in the source string.
+ |
+
char |
+next(char c)
+Consume the next character, and check that it matches a specified
+ character.
+ |
+
String |
+next(int n)
+Get the next n characters.
+ |
+
char |
+nextClean()
+Get the next char in the string, skipping whitespace.
+ |
+
String |
+nextString(char quote)
+Return the characters up to the next close quote character.
+ |
+
String |
+nextTo(char delimiter)
+Get the text up but not including the specified character or the
+ end of line, whichever comes first.
+ |
+
String |
+nextTo(String delimiters)
+Get the text up but not including one of the specified delimiter
+ characters or the end of line, whichever comes first.
+ |
+
Object |
+nextValue()
+Get the next value.
+ |
+
char |
+skipTo(char to)
+Skip characters until the next character is the requested character.
+ |
+
JSONException |
+syntaxError(String message)
+Make a JSONException to signal a syntax error.
+ |
+
JSONException |
+syntaxError(String message,
+ Throwable causedBy)
+Make a JSONException to signal a syntax error.
+ |
+
String |
+toString()
+Make a printable string of this JSONTokener.
+ |
+
public JSONTokener(Reader reader)+
reader - A reader.public JSONTokener(InputStream inputStream)+
inputStream - The source.public JSONTokener(String s)+
s - A source string.public void back() + throws JSONException+
JSONException - Thrown if trying to step back more than 1 step
+ or if already at the start of the stringpublic static int dehexchar(char c)+
c - A character between '0' and '9' or between 'A' and 'F' or
+ between 'a' and 'f'.public boolean end()+
public boolean more() + throws JSONException+
JSONException - thrown if there is an error stepping forward
+ or backward while checking for more data.public char next() + throws JSONException+
JSONException - Thrown if there is an error reading the source string.public char next(char c) + throws JSONException+
c - The character to match.JSONException - if the character does not match.public String next(int n) + throws JSONException+
n - The number of characters to take.JSONException - Substring bounds error if there are not
+ n characters remaining in the source string.public char nextClean() + throws JSONException+
JSONException - Thrown if there is an error reading the source string.public String nextString(char quote) + throws JSONException+
quote - The quoting character, either
+ " (double quote) or
+ ' (single quote).JSONException - Unterminated string.public String nextTo(char delimiter) + throws JSONException+
delimiter - A delimiter character.JSONException - Thrown if there is an error while searching
+ for the delimiterpublic String nextTo(String delimiters) + throws JSONException+
delimiters - A set of delimiter characters.JSONException - Thrown if there is an error while searching
+ for the delimiterpublic Object nextValue() + throws JSONException+
JSONException - If syntax error.public char skipTo(char to) + throws JSONException+
to - A character to skip to.JSONException - Thrown if there is an error while searching
+ for the to characterpublic JSONException syntaxError(String message)+
message - The error message.public JSONException syntaxError(String message, + Throwable causedBy)+
message - The error message.causedBy - The throwable that caused the error.public class JSONWriter
-extends java.lang.Object
-
- A JSONWriter instance provides a value method for appending
- values to the
- text, and a key
- method for adding keys before values in objects. There are array
- and endArray methods that make and bound array values, and
- object and endObject methods which make and bound
- object values. All of these methods return the JSONWriter instance,
- permitting a cascade style. For example,
- new JSONWriter(myWriter)
- .object()
- .key("JSON")
- .value("Hello, World!")
- .endObject(); which writes
- {"JSON":"Hello, World!"}
-
- The first method called must be array or object.
- There are no methods for adding commas or colons. JSONWriter adds them for
- you. Objects and arrays can be nested up to 20 levels deep.
-
- This can sometimes be easier than using a JSONObject to build a string.
| Modifier and Type | -Field and Description | -
|---|---|
protected char |
-mode
-The current mode.
- |
-
protected java.io.Writer |
-writer
-The writer that will receive the output.
- |
-
| Constructor and Description | -
|---|
JSONWriter(java.io.Writer w)
-Make a fresh JSONWriter.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
JSONWriter |
-array()
-Begin appending a new array.
- |
-
JSONWriter |
-endArray()
-End an array.
- |
-
JSONWriter |
-endObject()
-End an object.
- |
-
JSONWriter |
-key(java.lang.String string)
-Append a key.
- |
-
JSONWriter |
-object()
-Begin appending a new object.
- |
-
JSONWriter |
-value(boolean b)
-Append either the value
-true or the value
- false. |
-
JSONWriter |
-value(double d)
-Append a double value.
- |
-
JSONWriter |
-value(long l)
-Append a long value.
- |
-
JSONWriter |
-value(java.lang.Object object)
-Append an object value.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected char mode-
protected java.io.Writer writer-
public JSONWriter(java.io.Writer w)-
public JSONWriter array() - throws JSONException-
endArray will be appended to this array. The
- endArray method must be called to mark the array's end.JSONException - If the nesting is too deep, or if the object is
- started in the wrong place (for example as a key or after the end of the
- outermost array or object).public JSONWriter endArray() - throws JSONException-
array.JSONException - If incorrectly nested.public JSONWriter endObject() - throws JSONException-
object.JSONException - If incorrectly nested.public JSONWriter key(java.lang.String string) - throws JSONException-
string - A key string.JSONException - If the key is out of place. For example, keys
- do not belong in arrays or if the key is null.public JSONWriter object() - throws JSONException-
endObject will be appended to this object. The
- endObject method must be called to mark the object's end.JSONException - If the nesting is too deep, or if the object is
- started in the wrong place (for example as a key or after the end of the
- outermost array or object).public JSONWriter value(boolean b) - throws JSONException-
true or the value
- false.b - A boolean.JSONExceptionpublic JSONWriter value(double d) - throws JSONException-
d - A double.JSONException - If the number is not finite.public JSONWriter value(long l) - throws JSONException-
l - A long.JSONExceptionpublic JSONWriter value(java.lang.Object object) - throws JSONException-
object - The object to append. It can be null, or a Boolean, Number,
- String, JSONObject, or JSONArray, or an object that implements JSONString.JSONException - If the value is out of sequence.Copyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONWriter +extends Object+
+ A JSONWriter instance provides a value method for appending
+ values to the
+ text, and a key
+ method for adding keys before values in objects. There are array
+ and endArray methods that make and bound array values, and
+ object and endObject methods which make and bound
+ object values. All of these methods return the JSONWriter instance,
+ permitting a cascade style. For example,
+ new JSONWriter(myWriter)
+ .object()
+ .key("JSON")
+ .value("Hello, World!")
+ .endObject(); which writes
+ {"JSON":"Hello, World!"}
+
+ The first method called must be array or object.
+ There are no methods for adding commas or colons. JSONWriter adds them for
+ you. Objects and arrays can be nested up to 200 levels deep.
+
+ This can sometimes be easier than using a JSONObject to build a string.
| Modifier and Type | +Field and Description | +
|---|---|
protected char |
+mode
+The current mode.
+ |
+
protected Appendable |
+writer
+The writer that will receive the output.
+ |
+
| Constructor and Description | +
|---|
JSONWriter(Appendable w)
+Make a fresh JSONWriter.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
JSONWriter |
+array()
+Begin appending a new array.
+ |
+
JSONWriter |
+endArray()
+End an array.
+ |
+
JSONWriter |
+endObject()
+End an object.
+ |
+
JSONWriter |
+key(String string)
+Append a key.
+ |
+
JSONWriter |
+object()
+Begin appending a new object.
+ |
+
JSONWriter |
+value(boolean b)
+Append either the value
+true or the value
+ false. |
+
JSONWriter |
+value(double d)
+Append a double value.
+ |
+
JSONWriter |
+value(long l)
+Append a long value.
+ |
+
JSONWriter |
+value(Object object)
+Append an object value.
+ |
+
static String |
+valueToString(Object value)
+Make a JSON text of an Object value.
+ |
+
protected char mode+
protected Appendable writer+
public JSONWriter(Appendable w)+
w - an appendable objectpublic JSONWriter array() + throws JSONException+
endArray will be appended to this array. The
+ endArray method must be called to mark the array's end.JSONException - If the nesting is too deep, or if the object is
+ started in the wrong place (for example as a key or after the end of the
+ outermost array or object).public JSONWriter endArray() + throws JSONException+
array.JSONException - If incorrectly nested.public JSONWriter endObject() + throws JSONException+
object.JSONException - If incorrectly nested.public JSONWriter key(String string) + throws JSONException+
string - A key string.JSONException - If the key is out of place. For example, keys
+ do not belong in arrays or if the key is null.public JSONWriter object() + throws JSONException+
endObject will be appended to this object. The
+ endObject method must be called to mark the object's end.JSONException - If the nesting is too deep, or if the object is
+ started in the wrong place (for example as a key or after the end of the
+ outermost array or object).public static String valueToString(Object value) + throws JSONException+
+ Warning: This method assumes that the data structure is acyclical.
value - The value to be serialized.{ (left
+ brace) and ending with } (right
+ brace).JSONException - If the value is or contains an invalid number.public JSONWriter value(boolean b) + throws JSONException+
true or the value
+ false.b - A boolean.JSONException - if a called function has an errorpublic JSONWriter value(double d) + throws JSONException+
d - A double.JSONException - If the number is not finite.public JSONWriter value(long l) + throws JSONException+
l - A long.JSONException - if a called function has an errorpublic JSONWriter value(Object object) + throws JSONException+
object - The object to append. It can be null, or a Boolean, Number,
+ String, JSONObject, or JSONArray, or an object that implements JSONString.JSONException - If the value is out of sequence.public class Property
-extends java.lang.Object
-| Modifier and Type | -Method and Description | -
|---|---|
static JSONObject |
-toJSONObject(java.util.Properties properties)
-Converts a property file object into a JSONObject.
- |
-
static java.util.Properties |
-toProperties(JSONObject jo)
-Converts the JSONObject into a property file object.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static JSONObject toJSONObject(java.util.Properties properties) - throws JSONException-
properties - java.util.PropertiesJSONExceptionpublic static java.util.Properties toProperties(JSONObject jo) - throws JSONException-
jo - JSONObjectJSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class Property +extends Object+
| Modifier and Type | +Method and Description | +
|---|---|
static JSONObject |
+toJSONObject(Properties properties)
+Converts a property file object into a JSONObject.
+ |
+
static Properties |
+toProperties(JSONObject jo)
+Converts the JSONObject into a property file object.
+ |
+
public static JSONObject toJSONObject(Properties properties) + throws JSONException+
properties - java.util.PropertiesJSONException - if a called function has an errorpublic static Properties toProperties(JSONObject jo) + throws JSONException+
jo - JSONObjectJSONException - if a called function has an errorpublic class XML +extends Object+
| Modifier and Type | +Field and Description | +
|---|---|
static Character |
+AMP
+The Character '&'.
+ |
+
static Character |
+APOS
+The Character '''.
+ |
+
static Character |
+BANG
+The Character '!'.
+ |
+
static Character |
+EQ
+The Character '='.
+ |
+
static Character |
+GT
+The Character
+ |
+
static Character |
+LT
+The Character '<'.
+ |
+
static String |
+NULL_ATTR
+Null attribute name
+ |
+
static Character |
+QUEST
+The Character '?'.
+ |
+
static Character |
+QUOT
+The Character '"'.
+ |
+
static Character |
+SLASH
+The Character '/'.
+ |
+
static String |
+TYPE_ATTR |
+
| Modifier and Type | +Method and Description | +
|---|---|
static String |
+escape(String string)
+Replace special characters with XML escapes:
+ |
+
static void |
+noSpace(String string)
+Throw an exception if the string contains whitespace.
+ |
+
static Object |
+stringToValue(String string)
+This method is the same as
+JSONObject.stringToValue(String). |
+
static Object |
+stringToValue(String string,
+ XMLXsiTypeConverter<?> typeConverter)
+This method tries to convert the given string value to the target object
+ |
+
static JSONObject |
+toJSONObject(Reader reader)
+Convert a well-formed (but not necessarily valid) XML into a
+ JSONObject.
+ |
+
static JSONObject |
+toJSONObject(Reader reader,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML into a
+ JSONObject.
+ |
+
static JSONObject |
+toJSONObject(Reader reader,
+ XMLParserConfiguration config)
+Convert a well-formed (but not necessarily valid) XML into a
+ JSONObject.
+ |
+
static JSONObject |
+toJSONObject(String string)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject.
+ |
+
static JSONObject |
+toJSONObject(String string,
+ boolean keepStrings)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject.
+ |
+
static JSONObject |
+toJSONObject(String string,
+ XMLParserConfiguration config)
+Convert a well-formed (but not necessarily valid) XML string into a
+ JSONObject.
+ |
+
static String |
+toString(Object object)
+Convert a JSONObject into a well-formed, element-normal XML string.
+ |
+
static String |
+toString(Object object,
+ String tagName)
+Convert a JSONObject into a well-formed, element-normal XML string.
+ |
+
static String |
+toString(Object object,
+ String tagName,
+ XMLParserConfiguration config)
+Convert a JSONObject into a well-formed, element-normal XML string.
+ |
+
static String |
+unescape(String string)
+Removes XML escapes from the string.
+ |
+
public static final Character AMP+
public static final Character APOS+
public static final Character BANG+
public static final Character EQ+
public static final Character GT+
'>'. public static final Character LT+
public static final Character QUEST+
public static final Character QUOT+
public static final Character SLASH+
public static final String NULL_ATTR+
public static final String TYPE_ATTR+
public static String escape(String string)+
+ & (ampersand) is replaced by &amp;
+ < (less than) is replaced by &lt;
+ > (greater than) is replaced by &gt;
+ " (double quote) is replaced by &quot;
+ ' (single quote / apostrophe) is replaced by &apos;
+ string - The string to be escaped.public static String unescape(String string)+
string - string to remove escapes frompublic static void noSpace(String string) + throws JSONException+
string - A string.JSONException - Thrown if the string contains whitespace or is empty.public static Object stringToValue(String string, + XMLXsiTypeConverter<?> typeConverter)+
string - String to converttypeConverter - value converter to convert string to integer, boolean e.t.cpublic static Object stringToValue(String string)+
JSONObject.stringToValue(String).string - String to convertpublic static JSONObject toJSONObject(String string) + throws JSONException+
+ <[ [ ]]>
+ are ignored.string - The source string.JSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(Reader reader) + throws JSONException+
+ <[ [ ]]>
+ are ignored.reader - The XML source reader.JSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(Reader reader, + boolean keepStrings) + throws JSONException+
+ <[ [ ]]>
+ are ignored.
+
+ All values are converted as strings, for 1, 01, 29.0 will not be coerced to
+ numbers but will instead be the exact value as seen in the XML document.reader - The XML source reader.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(Reader reader, + XMLParserConfiguration config) + throws JSONException+
+ <[ [ ]]>
+ are ignored.
+
+ All values are converted as strings, for 1, 01, 29.0 will not be coerced to
+ numbers but will instead be the exact value as seen in the XML document.reader - The XML source reader.config - Configuration options for the parserJSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(String string, + boolean keepStrings) + throws JSONException+
+ <[ [ ]]>
+ are ignored.
+
+ All values are converted as strings, for 1, 01, 29.0 will not be coerced to
+ numbers but will instead be the exact value as seen in the XML document.string - The source string.keepStrings - If true, then values will not be coerced into boolean
+ or numeric values and will instead be left as stringsJSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(String string, + XMLParserConfiguration config) + throws JSONException+
+ <[ [ ]]>
+ are ignored.
+
+ All values are converted as strings, for 1, 01, 29.0 will not be coerced to
+ numbers but will instead be the exact value as seen in the XML document.string - The source string.config - Configuration options for the parser.JSONException - Thrown if there is an errors while parsing the stringpublic static String toString(Object object) + throws JSONException+
object - A JSONObject.JSONException - Thrown if there is an error parsing the stringpublic static String toString(Object object, + String tagName)+
object - A JSONObject.tagName - The optional name of the enclosing tag.JSONException - Thrown if there is an error parsing the stringpublic static String toString(Object object, + String tagName, + XMLParserConfiguration config) + throws JSONException+
object - A JSONObject.tagName - The optional name of the enclosing tag.config - Configuration that can control output to XML.JSONException - Thrown if there is an error parsing the stringpublic class XMLParserConfiguration +extends Object+
| Modifier and Type | +Field and Description | +
|---|---|
static XMLParserConfiguration |
+KEEP_STRINGS
+Original configuration of the XML Parser except that values are kept as strings.
+ |
+
static XMLParserConfiguration |
+ORIGINAL
+Original Configuration of the XML Parser.
+ |
+
| Constructor and Description | +
|---|
XMLParserConfiguration()
+Default parser configuration.
+ |
+
XMLParserConfiguration(boolean keepStrings)
+Deprecated.
+
+This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
XMLParserConfiguration(boolean keepStrings,
+ String cDataTagName)
+Deprecated.
+
+This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
XMLParserConfiguration(boolean keepStrings,
+ String cDataTagName,
+ boolean convertNilAttributeToNull)
+Deprecated.
+
+This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed or marked private in a future release.
+ |
+
XMLParserConfiguration(String cDataTagName)
+Deprecated.
+
+This constructor has been deprecated in favor of using the new builder
+ pattern for the configuration.
+ This constructor may be removed in a future release.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
protected XMLParserConfiguration |
+clone()
+Provides a new instance of the same configuration.
+ |
+
String |
+getcDataTagName()
+The name of the key in a JSON Object that indicates a CDATA section.
+ |
+
Map<String,XMLXsiTypeConverter<?>> |
+getXsiTypeMap()
+When parsing the XML into JSON, specifies that the values with attribute xsi:type
+ will be converted to target type defined to client in this configuration
+
+Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as string |
+
boolean |
+isConvertNilAttributeToNull()
+When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
+ should be kept as attribute(
+false), or they should be converted to
+ null(true) |
+
boolean |
+isKeepStrings()
+When parsing the XML into JSON, specifies if values should be kept as strings (
+true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string) |
+
XMLParserConfiguration |
+withcDataTagName(String newVal)
+The name of the key in a JSON Object that indicates a CDATA section.
+ |
+
XMLParserConfiguration |
+withConvertNilAttributeToNull(boolean newVal)
+When parsing the XML into JSON, specifies if values with attribute xsi:nil="true"
+ should be kept as attribute(
+false), or they should be converted to
+ null(true) |
+
XMLParserConfiguration |
+withKeepStrings(boolean newVal)
+When parsing the XML into JSON, specifies if values should be kept as strings (
+true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string) |
+
XMLParserConfiguration |
+withXsiTypeMap(Map<String,XMLXsiTypeConverter<?>> xsiTypeMap)
+When parsing the XML into JSON, specifies that the values with attribute xsi:type
+ will be converted to target type defined to client in this configuration
+
+Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as string |
+
public static final XMLParserConfiguration ORIGINAL+
public static final XMLParserConfiguration KEEP_STRINGS+
public XMLParserConfiguration()+
@Deprecated +public XMLParserConfiguration(boolean keepStrings)+
keepStrings - true to parse all values as string.
+ false to try and convert XML string values into a JSON value.@Deprecated +public XMLParserConfiguration(String cDataTagName)+
null to
+ disable CDATA processingcDataTagNamenull - to disable CDATA processing. Any other value
+ to use that value as the JSONObject key name to process as CDATA.@Deprecated +public XMLParserConfiguration(boolean keepStrings, + String cDataTagName)+
keepStrings - true to parse all values as string.
+ false to try and convert XML string values into a JSON value.cDataTagNamenull - to disable CDATA processing. Any other value
+ to use that value as the JSONObject key name to process as CDATA.@Deprecated +public XMLParserConfiguration(boolean keepStrings, + String cDataTagName, + boolean convertNilAttributeToNull)+
keepStrings - true to parse all values as string.
+ false to try and convert XML string values into a JSON value.cDataTagName - null to disable CDATA processing. Any other value
+ to use that value as the JSONObject key name to process as CDATA.convertNilAttributeToNull - true to parse values with attribute xsi:nil="true" as null.
+ false to parse values with attribute xsi:nil="true" as {"xsi:nil":true}.protected XMLParserConfiguration clone()+
public boolean isKeepStrings()+
true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string)keepStrings configuration value.public XMLParserConfiguration withKeepStrings(boolean newVal)+
true), or if
+ they should try to be guessed into JSON values (numeric, boolean, string)newVal - new value to use for the keepStrings configuration option.public String getcDataTagName()+
null to indicate no CDATA
+ processing.cDataTagName configuration value.public XMLParserConfiguration withcDataTagName(String newVal)+
null to indicate no CDATA
+ processing.newVal - new value to use for the cDataTagName configuration option.public boolean isConvertNilAttributeToNull()+
false), or they should be converted to
+ null(true)convertNilAttributeToNull configuration value.public XMLParserConfiguration withConvertNilAttributeToNull(boolean newVal)+
false), or they should be converted to
+ null(true)newVal - new value to use for the convertNilAttributeToNull configuration option.public Map<String,XMLXsiTypeConverter<?>> getXsiTypeMap()+
Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as stringxsiTypeMap unmodifiable configuration map.public XMLParserConfiguration withXsiTypeMap(Map<String,XMLXsiTypeConverter<?>> xsiTypeMap)+
Map<String, XMLXsiTypeConverter<?>> to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as stringxsiTypeMap - new HashMap<String, XMLXsiTypeConverter<?>>() to parse values with attribute
+ xsi:type="integer" as integer, xsi:type="string" as stringpublic class XMLTokener -extends JSONTokener-
| Modifier and Type | -Field and Description | -
|---|---|
static java.util.HashMap<java.lang.String,java.lang.Character> |
-entity
-The table of entity values.
- |
-
| Constructor and Description | -
|---|
XMLTokener(java.lang.String s)
-Construct an XMLTokener from a string.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
java.lang.String |
-nextCDATA()
-Get the text in the CDATA block.
- |
-
java.lang.Object |
-nextContent()
-Get the next XML outer token, trimming whitespace.
- |
-
java.lang.Object |
-nextEntity(char ampersand)
-Return the next entity.
- |
-
java.lang.Object |
-nextMeta()
-Returns the next XML meta token.
- |
-
java.lang.Object |
-nextToken()
-Get the next XML Token.
- |
-
boolean |
-skipPast(java.lang.String to)
-Skip characters until past the requested string.
- |
-
back, dehexchar, end, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, skipTo, syntaxError, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static final java.util.HashMap<java.lang.String,java.lang.Character> entity-
public XMLTokener(java.lang.String s)-
s - A source string.public java.lang.String nextCDATA() - throws JSONException-
]]>.JSONException - If the ]]> is not found.public java.lang.Object nextContent() - throws JSONException-
JSONExceptionpublic java.lang.Object nextEntity(char ampersand) - throws JSONException-
& ' > < ".ampersand - An ampersand character.JSONException - If missing ';' in XML entity.public java.lang.Object nextMeta() - throws JSONException-
< > / = ! ?) are returned as
- Character, and strings and names are returned as Boolean. We don't care
- what the values actually are.JSONException - If a string is not properly closed or if the XML
- is badly structured.public java.lang.Object nextToken() - throws JSONException-
/ > = ! ? or it
- may be a string wrapped in single quotes or double quotes, or it may be a
- name.JSONException - If the XML is not well formed.public boolean skipPast(java.lang.String to) - throws JSONException-
to - A string to skip past.JSONExceptionCopyright © 2016. All Rights Reserved.
- - + + + + + +public class XMLTokener +extends JSONTokener+
| Modifier and Type | +Field and Description | +
|---|---|
static HashMap<String,Character> |
+entity
+The table of entity values.
+ |
+
| Constructor and Description | +
|---|
XMLTokener(Reader r)
+Construct an XMLTokener from a Reader.
+ |
+
XMLTokener(String s)
+Construct an XMLTokener from a string.
+ |
+
| Modifier and Type | +Method and Description | +
|---|---|
String |
+nextCDATA()
+Get the text in the CDATA block.
+ |
+
Object |
+nextContent()
+Get the next XML outer token, trimming whitespace.
+ |
+
Object |
+nextEntity(char ampersand)
+{@code
+ Return the next entity.
+ |
+
Object |
+nextMeta()
+{@code
+ Returns the next XML meta token.
+ |
+
Object |
+nextToken()
+{@code
+ Get the next XML Token.
+ |
+
void |
+skipPast(String to)
+Skip characters until past the requested string.
+ |
+
back, dehexchar, end, more, next, next, next, nextClean, nextString, nextTo, nextTo, nextValue, skipTo, syntaxError, syntaxError, toStringpublic XMLTokener(Reader r)+
r - A source reader.public XMLTokener(String s)+
s - A source string.public String nextCDATA() + throws JSONException+
]]>.JSONException - If the ]]> is not found.public Object nextContent() + throws JSONException+
'<' character which begins a markup
+ tag, and the content
+ text between markup tags. '<' Character, or null if
+ there is no more source text.JSONException - if a called function has an errorpublic Object nextEntity(char ampersand) + throws JSONException+
+ Return the next entity. These entities are translated to Characters:
+ & ' > < ".
+ ampersand - An ampersand character.JSONException - If missing ';' in XML entity.public Object nextMeta() + throws JSONException+
+ Returns the next XML meta token. This is used for skipping over <!...>
+ and <?...?> structures.
+ Syntax characters (< > / = ! ?) are returned as
+ Character, and strings and names are returned as Boolean. We don't care
+ what the values actually are.
+ JSONException - If a string is not properly closed or if the XML
+ is badly structured.public Object nextToken() + throws JSONException+
+ Get the next XML Token. These tokens are found inside of angle
+ brackets. It may be one of these characters: / > = ! ? or it
+ may be a string wrapped in single quotes or double quotes, or it may be a
+ name.
+ JSONException - If the XML is not well formed.public void skipPast(String to)+
to - A string to skip past.T - return type of convert methodpublic interface XMLXsiTypeConverter<T>
++ XML Sample ++ <root> + <asString xsi:type="string">12345</asString> + <asInt xsi:type="integer">54321</asInt> + </root> ++ JSON Output ++ { + "root" : { + "asString" : "12345", + "asInt": 54321 + } + } ++ + Usage ++ Map<String, XMLXsiTypeConverter<?>> xsiTypeMap = new HashMap<String, XMLXsiTypeConverter<?>>(); + xsiTypeMap.put("string", new XMLXsiTypeConverter<String>() { + @Override public String convert(final String value) { + return value; + } + }); + xsiTypeMap.put("integer", new XMLXsiTypeConverter<Integer>() { + @Override public Integer convert(final String value) { + return Integer.valueOf(value); + } + }); ++
| Modifier and Type | +Method and Description | +
|---|---|
T |
+convert(String value) |
+
| Interface | -Description | -
|---|---|
| JSONString | -
- The
-JSONString interface allows a toJSONString()
- method so that a class can change the behavior of
- JSONObject.toString(), JSONArray.toString(),
- and JSONWriter.value(Object). |
-
| Class | -Description | -
|---|---|
| CDL | -
- This provides static methods to convert comma delimited text into a
- JSONArray, and to convert a JSONArray into comma delimited text.
- |
-
| Cookie | -
- Convert a web browser cookie specification to a JSONObject and back.
- |
-
| CookieList | -
- Convert a web browser cookie list string to a JSONObject and back.
- |
-
| HTTP | -
- Convert an HTTP header to a JSONObject and back.
- |
-
| HTTPTokener | -
- The HTTPTokener extends the JSONTokener to provide additional methods
- for the parsing of HTTP headers.
- |
-
| JSONArray | -
- A JSONArray is an ordered sequence of values.
- |
-
| JSONML | -
- This provides static methods to convert an XML text into a JSONArray or
- JSONObject, and to covert a JSONArray or JSONObject into an XML text using
- the JsonML transform.
- |
-
| JSONObject | -
- A JSONObject is an unordered collection of name/value pairs.
- |
-
| JSONStringer | -
- JSONStringer provides a quick and convenient way of producing JSON text.
- |
-
| JSONTokener | -
- A JSONTokener takes a source string and extracts characters and tokens from
- it.
- |
-
| JSONWriter | -
- JSONWriter provides a quick and convenient way of producing JSON text.
- |
-
| Property | -
- Converts a Property file data into JSONObject and back.
- |
-
| XML | -
- This provides static methods to convert an XML text into a JSONObject, and to
- covert a JSONObject into an XML text.
- |
-
| XMLTokener | -
- The XMLTokener extends the JSONTokener to provide additional methods
- for the parsing of XML texts.
- |
-
| Exception | -Description | -
|---|---|
| JSONException | -
- The JSONException is thrown by the JSON.org classes when things are amiss.
- |
-
Copyright © 2016. All Rights Reserved.
- - + + + + + +| Interface | +Description | +
|---|---|
| JSONString | +
+ The
+JSONString interface allows a toJSONString()
+ method so that a class can change the behavior of
+ JSONObject.toString(), JSONArray.toString(),
+ and JSONWriter.value(Object). |
+
| XMLXsiTypeConverter<T> | +
+ Type conversion configuration interface to be used with xsi:type attributes.
+ |
+
| Class | +Description | +
|---|---|
| CDL | +
+ This provides static methods to convert comma delimited text into a
+ JSONArray, and to convert a JSONArray into comma delimited text.
+ |
+
| Cookie | +
+ Convert a web browser cookie specification to a JSONObject and back.
+ |
+
| CookieList | +
+ Convert a web browser cookie list string to a JSONObject and back.
+ |
+
| HTTP | +
+ Convert an HTTP header to a JSONObject and back.
+ |
+
| HTTPTokener | +
+ The HTTPTokener extends the JSONTokener to provide additional methods
+ for the parsing of HTTP headers.
+ |
+
| JSONArray | +
+ A JSONArray is an ordered sequence of values.
+ |
+
| JSONML | +
+ This provides static methods to convert an XML text into a JSONArray or
+ JSONObject, and to covert a JSONArray or JSONObject into an XML text using
+ the JsonML transform.
+ |
+
| JSONObject | +
+ A JSONObject is an unordered collection of name/value pairs.
+ |
+
| JSONPointer | +
+ A JSON Pointer is a simple query language defined for JSON documents by
+ RFC 6901.
+ |
+
| JSONPointer.Builder | +
+ This class allows the user to build a JSONPointer in steps, using
+ exactly one segment in each step.
+ |
+
| JSONStringer | +
+ JSONStringer provides a quick and convenient way of producing JSON text.
+ |
+
| JSONTokener | +
+ A JSONTokener takes a source string and extracts characters and tokens from
+ it.
+ |
+
| JSONWriter | +
+ JSONWriter provides a quick and convenient way of producing JSON text.
+ |
+
| Property | +
+ Converts a Property file data into JSONObject and back.
+ |
+
| XML | +
+ This provides static methods to convert an XML text into a JSONObject, and to
+ covert a JSONObject into an XML text.
+ |
+
| XMLParserConfiguration | +
+ Configuration object for the XML parser.
+ |
+
| XMLTokener | +
+ The XMLTokener extends the JSONTokener to provide additional methods
+ for the parsing of XML texts.
+ |
+
| Exception | +Description | +
|---|---|
| JSONException | +
+ The JSONException is thrown by the JSON.org classes when things are amiss.
+ |
+
| JSONPointerException | +
+ The JSONPointerException is thrown by
+JSONPointer if an error occurs
+ during evaluating a pointer. |
+
| Annotation Type | +Description | +
|---|---|
| JSONPropertyIgnore | ++ |
| JSONPropertyName | ++ |
Copyright © 2016. All Rights Reserved.
- - + + + + + +Copyright © 2016. All Rights Reserved.
- - + + + + + +Copyright © 2016. All Rights Reserved.
- - + + + + + +public class JSONObject
-extends java.lang.Object
-get and opt methods for accessing
- the values by name, and put methods for adding or replacing
- values by name. The values can be any of these types: Boolean,
- JSONArray, JSONObject, Number,
- String, or the JSONObject.NULL object. A
- JSONObject constructor can be used to convert an external form JSON text
- into an internal form whose values can be retrieved with the
- get and opt methods, or to convert values into a
- JSON text using the put and toString methods. A
- get method returns a value if one can be found, and throws an
- exception if one cannot be found. An opt method returns a
- default value instead of throwing an exception, and so is useful for
- obtaining optional values.
-
- The generic get() and opt() methods return an
- object, which you can cast or query for type. There are also typed
- get and opt methods that do type checking and type
- coercion for you. The opt methods differ from the get methods in that they
- do not throw. Instead, they return a specified value, such as null.
-
- The put methods add or replace values in an object. For
- example,
-
-
- myString = new JSONObject()
- .put("JSON", "Hello, World!").toString();
-
-
- produces the string {"JSON": "Hello, World"}.
-
- The texts produced by the toString methods strictly conform to
- the JSON syntax rules. The constructors are more forgiving in the texts they
- will accept:
-
, (comma) may appear just
- before the closing brace.' (single
- quote).{ } [ ] / \ : , # and if they do not look like numbers and
- if they are not the reserved words true, false,
- or null.| Modifier and Type | -Field and Description | -
|---|---|
static java.lang.Object |
-NULL
-It is sometimes more convenient and less ambiguous to have a
-
-NULL object than to use Java's null value. |
-
| Constructor and Description | -
|---|
JSONObject()
-Construct an empty JSONObject.
- |
-
JSONObject(JSONObject jo,
- java.lang.String[] names)
-Construct a JSONObject from a subset of another JSONObject.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
JSONObject(java.util.Map<?,?> map)
-Construct a JSONObject from a Map.
- |
-
JSONObject(java.lang.Object bean)
-Construct a JSONObject from an Object using bean getters.
- |
-
JSONObject(java.lang.Object object,
- java.lang.String[] names)
-Construct a JSONObject from an Object, using reflection to find the
- public members.
- |
-
JSONObject(java.lang.String source)
-Construct a JSONObject from a source JSON text string.
- |
-
JSONObject(java.lang.String baseName,
- java.util.Locale locale)
-Construct a JSONObject from a ResourceBundle.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
JSONObject |
-accumulate(java.lang.String key,
- java.lang.Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-append(java.lang.String key,
- java.lang.Object value)
-Append values to the array under a key.
- |
-
static java.lang.String |
-doubleToString(double d)
-Produce a string from a double.
- |
-
java.lang.Object |
-get(java.lang.String key)
-Get the value object associated with a key.
- |
-
java.math.BigDecimal |
-getBigDecimal(java.lang.String key)
-Get the BigDecimal value associated with a key.
- |
-
java.math.BigInteger |
-getBigInteger(java.lang.String key)
-Get the BigInteger value associated with a key.
- |
-
boolean |
-getBoolean(java.lang.String key)
-Get the boolean value associated with a key.
- |
-
double |
-getDouble(java.lang.String key)
-Get the double value associated with a key.
- |
-
<E extends java.lang.Enum<E>> |
-getEnum(java.lang.Class<E> clazz,
- java.lang.String key)
-Get the enum value associated with a key.
- |
-
int |
-getInt(java.lang.String key)
-Get the int value associated with a key.
- |
-
JSONArray |
-getJSONArray(java.lang.String key)
-Get the JSONArray value associated with a key.
- |
-
JSONObject |
-getJSONObject(java.lang.String key)
-Get the JSONObject value associated with a key.
- |
-
long |
-getLong(java.lang.String key)
-Get the long value associated with a key.
- |
-
static java.lang.String[] |
-getNames(JSONObject jo)
-Get an array of field names from a JSONObject.
- |
-
static java.lang.String[] |
-getNames(java.lang.Object object)
-Get an array of field names from an Object.
- |
-
java.lang.String |
-getString(java.lang.String key)
-Get the string associated with a key.
- |
-
boolean |
-has(java.lang.String key)
-Determine if the JSONObject contains a specific key.
- |
-
JSONObject |
-increment(java.lang.String key)
-Increment a property of a JSONObject.
- |
-
boolean |
-isNull(java.lang.String key)
-Determine if the value associated with the key is null or if there is no
- value.
- |
-
java.util.Iterator<java.lang.String> |
-keys()
-Get an enumeration of the keys of the JSONObject.
- |
-
java.util.Set<java.lang.String> |
-keySet()
-Get a set of keys of the JSONObject.
- |
-
int |
-length()
-Get the number of keys stored in the JSONObject.
- |
-
JSONArray |
-names()
-Produce a JSONArray containing the names of the elements of this
- JSONObject.
- |
-
static java.lang.String |
-numberToString(java.lang.Number number)
-Produce a string from a Number.
- |
-
java.lang.Object |
-opt(java.lang.String key)
-Get an optional value associated with a key.
- |
-
java.math.BigDecimal |
-optBigDecimal(java.lang.String key,
- java.math.BigDecimal defaultValue)
-Get an optional BigDecimal associated with a key, or the defaultValue if
- there is no such key or if its value is not a number.
- |
-
java.math.BigInteger |
-optBigInteger(java.lang.String key,
- java.math.BigInteger defaultValue)
-Get an optional BigInteger associated with a key, or the defaultValue if
- there is no such key or if its value is not a number.
- |
-
boolean |
-optBoolean(java.lang.String key)
-Get an optional boolean associated with a key.
- |
-
boolean |
-optBoolean(java.lang.String key,
- boolean defaultValue)
-Get an optional boolean associated with a key.
- |
-
double |
-optDouble(java.lang.String key)
-Get an optional double associated with a key, or NaN if there is no such
- key or if its value is not a number.
- |
-
double |
-optDouble(java.lang.String key,
- double defaultValue)
-Get an optional double associated with a key, or the defaultValue if
- there is no such key or if its value is not a number.
- |
-
<E extends java.lang.Enum<E>> |
-optEnum(java.lang.Class<E> clazz,
- java.lang.String key)
-Get the enum value associated with a key.
- |
-
<E extends java.lang.Enum<E>> |
-optEnum(java.lang.Class<E> clazz,
- java.lang.String key,
- E defaultValue)
-Get the enum value associated with a key.
- |
-
int |
-optInt(java.lang.String key)
-Get an optional int value associated with a key, or zero if there is no
- such key or if the value is not a number.
- |
-
int |
-optInt(java.lang.String key,
- int defaultValue)
-Get an optional int value associated with a key, or the default if there
- is no such key or if the value is not a number.
- |
-
JSONArray |
-optJSONArray(java.lang.String key)
-Get an optional JSONArray associated with a key.
- |
-
JSONObject |
-optJSONObject(java.lang.String key)
-Get an optional JSONObject associated with a key.
- |
-
long |
-optLong(java.lang.String key)
-Get an optional long value associated with a key, or zero if there is no
- such key or if the value is not a number.
- |
-
long |
-optLong(java.lang.String key,
- long defaultValue)
-Get an optional long value associated with a key, or the default if there
- is no such key or if the value is not a number.
- |
-
java.lang.String |
-optString(java.lang.String key)
-Get an optional string associated with a key.
- |
-
java.lang.String |
-optString(java.lang.String key,
- java.lang.String defaultValue)
-Get an optional string associated with a key.
- |
-
JSONObject |
-put(java.lang.String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-put(java.lang.String key,
- java.util.Collection<?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONArray which is produced from a Collection.
- |
-
JSONObject |
-put(java.lang.String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-put(java.lang.String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-put(java.lang.String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-put(java.lang.String key,
- java.util.Map<?,?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-put(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-putOnce(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-putOpt(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
static java.lang.String |
-quote(java.lang.String string)
-Produce a string in double quotes with backslash sequences in all the
- right places.
- |
-
static java.io.Writer |
-quote(java.lang.String string,
- java.io.Writer w) |
-
java.lang.Object |
-remove(java.lang.String key)
-Remove a name and its value, if present.
- |
-
boolean |
-similar(java.lang.Object other)
-Determine if two JSONObjects are similar.
- |
-
static java.lang.Object |
-stringToValue(java.lang.String string)
-Try to convert a string into a number, boolean, or null.
- |
-
static void |
-testValidity(java.lang.Object o)
-Throw an exception if the object is a NaN or infinite number.
- |
-
JSONArray |
-toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
java.lang.String |
-toString()
-Make a JSON text of this JSONObject.
- |
-
java.lang.String |
-toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONObject.
- |
-
static java.lang.String |
-valueToString(java.lang.Object value)
-Make a JSON text of an Object value.
- |
-
static java.lang.Object |
-wrap(java.lang.Object object)
-Wrap an object, if necessary.
- |
-
java.io.Writer |
-write(java.io.Writer writer)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
java.io.Writer |
-write(java.io.Writer writer,
- int indentFactor,
- int indent)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic static final java.lang.Object NULL-
NULL object than to use Java's null value.
- JSONObject.NULL.equals(null) returns true.
- JSONObject.NULL.toString() returns "null".public JSONObject()-
public JSONObject(JSONObject jo, - java.lang.String[] names)-
jo - A JSONObject.names - An array of strings.public JSONObject(JSONTokener x) - throws JSONException-
x - A JSONTokener object containing the source string.JSONException - If there is a syntax error in the source string or a
- duplicated key.public JSONObject(java.util.Map<?,?> map)-
map - A map object that can be used to initialize the contents of
- the JSONObject.public JSONObject(java.lang.Object bean)-
"get" or
- "is" followed by an uppercase letter, the method is invoked,
- and a key and the value returned from the getter method are put into the
- new JSONObject.
-
- The key is formed by removing the "get" or "is"
- prefix. If the second remaining character is not upper case, then the
- first character is converted to lower case.
-
- For example, if an object has a method named "getName", and
- if the result of calling object.getName() is
- "Larry Fine", then the JSONObject will contain
- "name": "Larry Fine".bean - An object that has getter methods that should be used to make
- a JSONObject.public JSONObject(java.lang.Object object, - java.lang.String[] names)-
object - An object that has fields that should be used to make a
- JSONObject.names - An array of strings, the names of the fields to be obtained
- from the object.public JSONObject(java.lang.String source) - throws JSONException-
source - A string beginning with { (left
- brace) and ending with }
- (right brace).JSONException - If there is a syntax error in the source string or a
- duplicated key.public JSONObject(java.lang.String baseName, - java.util.Locale locale) - throws JSONException-
baseName - The ResourceBundle base name.locale - The Locale to load the ResourceBundle for.JSONException - If any JSONExceptions are detected.public JSONObject accumulate(java.lang.String key, - java.lang.Object value) - throws JSONException-
key - A key string.value - An object to be accumulated under the key.JSONException - If the value is an invalid number or if the key is null.public JSONObject append(java.lang.String key, - java.lang.Object value) - throws JSONException-
key - A key string.value - An object to be accumulated under the key.JSONException - If the key is null or if the current value associated with
- the key is not a JSONArray.public static java.lang.String doubleToString(double d)-
d - A double.public java.lang.Object get(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found.public <E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> clazz, - java.lang.String key) - throws JSONException-
clazz - The type of enum to retrieve.key - A key string.JSONException - if the key is not found or if the value cannot be converted
- to an enum.public boolean getBoolean(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the value is not a Boolean or the String "true" or
- "false".public java.math.BigInteger getBigInteger(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value cannot
- be converted to BigInteger.public java.math.BigDecimal getBigDecimal(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value
- cannot be converted to BigDecimal.public double getDouble(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value is not a Number
- object and cannot be converted to a number.public int getInt(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value cannot be converted
- to an integer.public JSONArray getJSONArray(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value is not a JSONArray.public JSONObject getJSONObject(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value is not a JSONObject.public long getLong(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if the key is not found or if the value cannot be converted
- to a long.public static java.lang.String[] getNames(JSONObject jo)-
public static java.lang.String[] getNames(java.lang.Object object)-
public java.lang.String getString(java.lang.String key) - throws JSONException-
key - A key string.JSONException - if there is no string value for the key.public boolean has(java.lang.String key)-
key - A key string.public JSONObject increment(java.lang.String key) - throws JSONException-
key - A key string.JSONException - If there is already a property with this name that is not an
- Integer, Long, Double, or Float.public boolean isNull(java.lang.String key)-
key - A key string.public java.util.Iterator<java.lang.String> keys()-
public java.util.Set<java.lang.String> keySet()-
public int length()-
public JSONArray names()-
public static java.lang.String numberToString(java.lang.Number number) - throws JSONException-
number - A NumberJSONException - If n is a non-finite number.public java.lang.Object opt(java.lang.String key)-
key - A key string.public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz, - java.lang.String key)-
clazz - The type of enum to retrieve.key - A key string.public <E extends java.lang.Enum<E>> E optEnum(java.lang.Class<E> clazz, - java.lang.String key, - E defaultValue)-
clazz - The type of enum to retrieve.key - A key string.defaultValue - The default in case the value is not foundpublic boolean optBoolean(java.lang.String key)-
key - A key string.public boolean optBoolean(java.lang.String key, - boolean defaultValue)-
key - A key string.defaultValue - The default.public double optDouble(java.lang.String key)-
key - A string which is the key.public java.math.BigInteger optBigInteger(java.lang.String key, - java.math.BigInteger defaultValue)-
key - A key string.defaultValue - The default.public java.math.BigDecimal optBigDecimal(java.lang.String key, - java.math.BigDecimal defaultValue)-
key - A key string.defaultValue - The default.public double optDouble(java.lang.String key, - double defaultValue)-
key - A key string.defaultValue - The default.public int optInt(java.lang.String key)-
key - A key string.public int optInt(java.lang.String key, - int defaultValue)-
key - A key string.defaultValue - The default.public JSONArray optJSONArray(java.lang.String key)-
key - A key string.public JSONObject optJSONObject(java.lang.String key)-
key - A key string.public long optLong(java.lang.String key)-
key - A key string.public long optLong(java.lang.String key, - long defaultValue)-
key - A key string.defaultValue - The default.public java.lang.String optString(java.lang.String key)-
key - A key string.public java.lang.String optString(java.lang.String key, - java.lang.String defaultValue)-
key - A key string.defaultValue - The default.public JSONObject put(java.lang.String key, - boolean value) - throws JSONException-
key - A key string.value - A boolean which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, - java.util.Collection<?> value) - throws JSONException-
key - A key string.value - A Collection value.JSONExceptionpublic JSONObject put(java.lang.String key, - double value) - throws JSONException-
key - A key string.value - A double which is the value.JSONException - If the key is null or if the number is invalid.public JSONObject put(java.lang.String key, - int value) - throws JSONException-
key - A key string.value - An int which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, - long value) - throws JSONException-
key - A key string.value - A long which is the value.JSONException - If the key is null.public JSONObject put(java.lang.String key, - java.util.Map<?,?> value) - throws JSONException-
key - A key string.value - A Map value.JSONExceptionpublic JSONObject put(java.lang.String key, - java.lang.Object value) - throws JSONException-
key - A key string.value - An object which is the value. It should be of one of these
- types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
- String, or the JSONObject.NULL object.JSONException - If the value is non-finite number or if the key is null.public JSONObject putOnce(java.lang.String key, - java.lang.Object value) - throws JSONException-
key - stringvalue - objectJSONException - if the key is a duplicatepublic JSONObject putOpt(java.lang.String key, - java.lang.Object value) - throws JSONException-
key - A key string.value - An object which is the value. It should be of one of these
- types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
- String, or the JSONObject.NULL object.JSONException - If the value is a non-finite number.public static java.lang.String quote(java.lang.String string)-
string - A Stringpublic static java.io.Writer quote(java.lang.String string, - java.io.Writer w) - throws java.io.IOException-
java.io.IOExceptionpublic java.lang.Object remove(java.lang.String key)-
key - The name to be removed.public boolean similar(java.lang.Object other)-
other - The other JSONObjectpublic static java.lang.Object stringToValue(java.lang.String string)-
string - A String.public static void testValidity(java.lang.Object o) - throws JSONException-
o - The object to test.JSONException - If o is a non-finite number.public JSONArray toJSONArray(JSONArray names) - throws JSONException-
names - A JSONArray containing a list of key strings. This determines
- the sequence of the values in the result.JSONException - If any of the values are non-finite numbers.public java.lang.String toString()-
- Warning: This method assumes that the data structure is acyclical.
toString in class java.lang.Object{ (left
- brace) and ending with } (right
- brace).public java.lang.String toString(int indentFactor) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
indentFactor - The number of spaces to add to each level of indentation.{ (left
- brace) and ending with } (right
- brace).JSONException - If the object contains an invalid number.public static java.lang.String valueToString(java.lang.Object value) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
value - The value to be serialized.{ (left
- brace) and ending with } (right
- brace).JSONException - If the value is or contains an invalid number.public static java.lang.Object wrap(java.lang.Object object)-
object - The object to wrappublic java.io.Writer write(java.io.Writer writer) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
JSONExceptionpublic java.io.Writer write(java.io.Writer writer, - int indentFactor, - int indent) - throws JSONException-
- Warning: This method assumes that the data structure is acyclical.
writer - Writes the serialized JSONindentFactor - The number of spaces to add to each level of indentation.indent - The indention of the top level.JSONExceptionCopyright © 2016. All Rights Reserved.
- - diff --git a/org/json/XML.html b/org/json/XML.html deleted file mode 100644 index 6f5515d..0000000 --- a/org/json/XML.html +++ /dev/null @@ -1,606 +0,0 @@ - - - - - - -public class XML
-extends java.lang.Object
-| Modifier and Type | -Field and Description | -
|---|---|
static java.lang.Character |
-AMP
-The Character '&'.
- |
-
static java.lang.Character |
-APOS
-The Character '''.
- |
-
static java.lang.Character |
-BANG
-The Character '!'.
- |
-
static java.lang.Character |
-EQ
-The Character '='.
- |
-
static java.lang.Character |
-GT
-The Character '>'.
- |
-
static java.lang.Character |
-LT
-The Character '<'.
- |
-
static java.lang.Character |
-QUEST
-The Character '?'.
- |
-
static java.lang.Character |
-QUOT
-The Character '"'.
- |
-
static java.lang.Character |
-SLASH
-The Character '/'.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
static java.lang.String |
-escape(java.lang.String string)
-Replace special characters with XML escapes:
-
-
- & (ampersand) is replaced by &
- < (less than) is replaced by <
- > (greater than) is replaced by >
- " (double quote) is replaced by "
-
- |
-
static void |
-noSpace(java.lang.String string)
-Throw an exception if the string contains whitespace.
- |
-
static java.lang.Object |
-stringToValue(java.lang.String string)
-Deprecated.
-
-Use
-JSONObject.stringToValue(String) instead. |
-
static JSONObject |
-toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject.
- |
-
static java.lang.String |
-toString(java.lang.Object object)
-Convert a JSONObject into a well-formed, element-normal XML string.
- |
-
static java.lang.String |
-toString(java.lang.Object object,
- java.lang.String tagName)
-Convert a JSONObject into a well-formed, element-normal XML string.
- |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static final java.lang.Character AMP-
public static final java.lang.Character APOS-
public static final java.lang.Character BANG-
public static final java.lang.Character EQ-
public static final java.lang.Character GT-
public static final java.lang.Character LT-
public static final java.lang.Character QUEST-
public static final java.lang.Character QUOT-
public static final java.lang.Character SLASH-
public static java.lang.String escape(java.lang.String string)-
- & (ampersand) is replaced by & - < (less than) is replaced by < - > (greater than) is replaced by > - " (double quote) is replaced by " -
string - The string to be escaped.public static void noSpace(java.lang.String string) - throws JSONException-
string - A string.JSONExceptionpublic static java.lang.Object stringToValue(java.lang.String string)-
JSONObject.stringToValue(String) instead.JSONObject.stringToValue(String) method. Use it instead.string - public static JSONObject toJSONObject(java.lang.String string) - throws JSONException-
<[ [ ]]>
- are ignored.string - The source string.JSONExceptionpublic static java.lang.String toString(java.lang.Object object) - throws JSONException-
object - A JSONObject.JSONExceptionpublic static java.lang.String toString(java.lang.Object object, - java.lang.String tagName) - throws JSONException-
object - A JSONObject.tagName - The optional name of the enclosing tag.JSONExceptionCopyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/CDL.html b/org/json/class-use/CDL.html deleted file mode 100644 index 38e2a10..0000000 --- a/org/json/class-use/CDL.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/Cookie.html b/org/json/class-use/Cookie.html deleted file mode 100644 index e9abd09..0000000 --- a/org/json/class-use/Cookie.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/CookieList.html b/org/json/class-use/CookieList.html deleted file mode 100644 index d2028d9..0000000 --- a/org/json/class-use/CookieList.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/HTTP.html b/org/json/class-use/HTTP.html deleted file mode 100644 index 158ed56..0000000 --- a/org/json/class-use/HTTP.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/HTTPTokener.html b/org/json/class-use/HTTPTokener.html deleted file mode 100644 index 9050b2c..0000000 --- a/org/json/class-use/HTTPTokener.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONArray.html b/org/json/class-use/JSONArray.html deleted file mode 100644 index 214969c..0000000 --- a/org/json/class-use/JSONArray.html +++ /dev/null @@ -1,401 +0,0 @@ - - - - - - -| Modifier and Type | -Method and Description | -
|---|---|
JSONArray |
-JSONArray.getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.getJSONArray(java.lang.String key)
-Get the JSONArray value associated with a key.
- |
-
JSONArray |
-JSONObject.names()
-Produce a JSONArray containing the names of the elements of this
- JSONObject.
- |
-
JSONArray |
-JSONArray.optJSONArray(int index)
-Get the optional JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.optJSONArray(java.lang.String key)
-Get an optional JSONArray associated with a key.
- |
-
JSONArray |
-JSONArray.put(boolean value)
-Append a boolean value.
- |
-
JSONArray |
-JSONArray.put(java.util.Collection<?> value)
-Put a value in the JSONArray, where the value will be a JSONArray which
- is produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(double value)
-Append a double value.
- |
-
JSONArray |
-JSONArray.put(int value)
-Append an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.util.Collection<?> value)
-Put a value in the JSONArray, where the value will be a JSONArray which
- is produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.util.Map<?,?> value)
-Put a value in the JSONArray, where the value will be a JSONObject that
- is produced from a Map.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.lang.Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(long value)
-Append an long value.
- |
-
JSONArray |
-JSONArray.put(java.util.Map<?,?> value)
-Put a value in the JSONArray, where the value will be a JSONObject which
- is produced from a Map.
- |
-
JSONArray |
-JSONArray.put(java.lang.Object value)
-Append an object value.
- |
-
static JSONArray |
-CDL.rowToJSONArray(JSONTokener x)
-Produce a JSONArray of strings from a row of comma delimited values.
- |
-
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static JSONArray |
-JSONML.toJSONArray(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
static JSONArray |
-CDL.toJSONArray(java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static JSONArray |
-JSONML.toJSONArray(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
static JSONObject |
-CDL.rowToJSONObject(JSONArray names,
- JSONTokener x)
-Produce a JSONObject from a row of comma delimited text, using a
- parallel JSONArray of strings to provides the names of the elements.
- |
-
static java.lang.String |
-CDL.rowToString(JSONArray ja)
-Produce a comma delimited text row from a JSONArray.
- |
-
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
static java.lang.String |
-JSONML.toString(JSONArray ja)
-Reverse the JSONML transformation, making an XML text from a JSONArray.
- |
-
static java.lang.String |
-CDL.toString(JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects.
- |
-
static java.lang.String |
-CDL.toString(JSONArray names,
- JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects using
- a provided list of names.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONException.html b/org/json/class-use/JSONException.html deleted file mode 100644 index 39fecbd..0000000 --- a/org/json/class-use/JSONException.html +++ /dev/null @@ -1,900 +0,0 @@ - - - - - - -| Modifier and Type | -Method and Description | -
|---|---|
JSONException |
-JSONTokener.syntaxError(java.lang.String message)
-Make a JSONException to signal a syntax error.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
JSONObject |
-JSONObject.accumulate(java.lang.String key,
- java.lang.Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-JSONObject.append(java.lang.String key,
- java.lang.Object value)
-Append values to the array under a key.
- |
-
JSONWriter |
-JSONWriter.array()
-Begin appending a new array.
- |
-
void |
-JSONTokener.back()
-Back up one character.
- |
-
JSONWriter |
-JSONWriter.endArray()
-End an array.
- |
-
JSONWriter |
-JSONWriter.endObject()
-End an object.
- |
-
java.lang.Object |
-JSONArray.get(int index)
-Get the object value associated with an index.
- |
-
java.lang.Object |
-JSONObject.get(java.lang.String key)
-Get the value object associated with a key.
- |
-
java.math.BigDecimal |
-JSONArray.getBigDecimal(int index)
-Get the BigDecimal value associated with an index.
- |
-
java.math.BigDecimal |
-JSONObject.getBigDecimal(java.lang.String key)
-Get the BigDecimal value associated with a key.
- |
-
java.math.BigInteger |
-JSONArray.getBigInteger(int index)
-Get the BigInteger value associated with an index.
- |
-
java.math.BigInteger |
-JSONObject.getBigInteger(java.lang.String key)
-Get the BigInteger value associated with a key.
- |
-
boolean |
-JSONArray.getBoolean(int index)
-Get the boolean value associated with an index.
- |
-
boolean |
-JSONObject.getBoolean(java.lang.String key)
-Get the boolean value associated with a key.
- |
-
double |
-JSONArray.getDouble(int index)
-Get the double value associated with an index.
- |
-
double |
-JSONObject.getDouble(java.lang.String key)
-Get the double value associated with a key.
- |
-
<E extends java.lang.Enum<E>> |
-JSONArray.getEnum(java.lang.Class<E> clazz,
- int index)
-Get the enum value associated with an index.
- |
-
<E extends java.lang.Enum<E>> |
-JSONObject.getEnum(java.lang.Class<E> clazz,
- java.lang.String key)
-Get the enum value associated with a key.
- |
-
int |
-JSONArray.getInt(int index)
-Get the int value associated with an index.
- |
-
int |
-JSONObject.getInt(java.lang.String key)
-Get the int value associated with a key.
- |
-
JSONArray |
-JSONArray.getJSONArray(int index)
-Get the JSONArray associated with an index.
- |
-
JSONArray |
-JSONObject.getJSONArray(java.lang.String key)
-Get the JSONArray value associated with a key.
- |
-
JSONObject |
-JSONArray.getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.getJSONObject(java.lang.String key)
-Get the JSONObject value associated with a key.
- |
-
long |
-JSONArray.getLong(int index)
-Get the long value associated with an index.
- |
-
long |
-JSONObject.getLong(java.lang.String key)
-Get the long value associated with a key.
- |
-
java.lang.String |
-JSONArray.getString(int index)
-Get the string associated with an index.
- |
-
java.lang.String |
-JSONObject.getString(java.lang.String key)
-Get the string associated with a key.
- |
-
JSONObject |
-JSONObject.increment(java.lang.String key)
-Increment a property of a JSONObject.
- |
-
java.lang.String |
-JSONArray.join(java.lang.String separator)
-Make a string from the contents of this JSONArray.
- |
-
JSONWriter |
-JSONWriter.key(java.lang.String string)
-Append a key.
- |
-
boolean |
-JSONTokener.more()
-Determine if the source string still contains characters that next()
- can consume.
- |
-
char |
-JSONTokener.next()
-Get the next character in the source string.
- |
-
char |
-JSONTokener.next(char c)
-Consume the next character, and check that it matches a specified
- character.
- |
-
java.lang.String |
-JSONTokener.next(int n)
-Get the next n characters.
- |
-
java.lang.String |
-XMLTokener.nextCDATA()
-Get the text in the CDATA block.
- |
-
char |
-JSONTokener.nextClean()
-Get the next char in the string, skipping whitespace.
- |
-
java.lang.Object |
-XMLTokener.nextContent()
-Get the next XML outer token, trimming whitespace.
- |
-
java.lang.Object |
-XMLTokener.nextEntity(char ampersand)
-Return the next entity.
- |
-
java.lang.Object |
-XMLTokener.nextMeta()
-Returns the next XML meta token.
- |
-
java.lang.String |
-JSONTokener.nextString(char quote)
-Return the characters up to the next close quote character.
- |
-
java.lang.String |
-JSONTokener.nextTo(char delimiter)
-Get the text up but not including the specified character or the
- end of line, whichever comes first.
- |
-
java.lang.String |
-JSONTokener.nextTo(java.lang.String delimiters)
-Get the text up but not including one of the specified delimiter
- characters or the end of line, whichever comes first.
- |
-
java.lang.Object |
-XMLTokener.nextToken()
-Get the next XML Token.
- |
-
java.lang.String |
-HTTPTokener.nextToken()
-Get the next token or string.
- |
-
java.lang.Object |
-JSONTokener.nextValue()
-Get the next value.
- |
-
static void |
-XML.noSpace(java.lang.String string)
-Throw an exception if the string contains whitespace.
- |
-
static java.lang.String |
-JSONObject.numberToString(java.lang.Number number)
-Produce a string from a Number.
- |
-
JSONWriter |
-JSONWriter.object()
-Begin appending a new object.
- |
-
JSONArray |
-JSONArray.put(double value)
-Append a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- boolean value)
-Put or replace a boolean value in the JSONArray.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.util.Collection<?> value)
-Put a value in the JSONArray, where the value will be a JSONArray which
- is produced from a Collection.
- |
-
JSONArray |
-JSONArray.put(int index,
- double value)
-Put or replace a double value.
- |
-
JSONArray |
-JSONArray.put(int index,
- int value)
-Put or replace an int value.
- |
-
JSONArray |
-JSONArray.put(int index,
- long value)
-Put or replace a long value.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.util.Map<?,?> value)
-Put a value in the JSONArray, where the value will be a JSONObject that
- is produced from a Map.
- |
-
JSONArray |
-JSONArray.put(int index,
- java.lang.Object value)
-Put or replace an object value in the JSONArray.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.util.Collection<?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONArray which is produced from a Collection.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.util.Map<?,?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.putOnce(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-JSONObject.putOpt(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
static JSONArray |
-CDL.rowToJSONArray(JSONTokener x)
-Produce a JSONArray of strings from a row of comma delimited values.
- |
-
static JSONObject |
-CDL.rowToJSONObject(JSONArray names,
- JSONTokener x)
-Produce a JSONObject from a row of comma delimited text, using a
- parallel JSONArray of strings to provides the names of the elements.
- |
-
boolean |
-XMLTokener.skipPast(java.lang.String to)
-Skip characters until past the requested string.
- |
-
char |
-JSONTokener.skipTo(char to)
-Skip characters until the next character is the requested character.
- |
-
static void |
-JSONObject.testValidity(java.lang.Object o)
-Throw an exception if the object is a NaN or infinite number.
- |
-
JSONArray |
-JSONObject.toJSONArray(JSONArray names)
-Produce a JSONArray containing the values of the members of this
- JSONObject.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static JSONArray |
-JSONML.toJSONArray(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
static JSONArray |
-CDL.toJSONArray(java.lang.String string)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
static JSONArray |
-JSONML.toJSONArray(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
static JSONObject |
-Property.toJSONObject(java.util.Properties properties)
-Converts a property file object into a JSONObject.
- |
-
static JSONObject |
-XML.toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject.
- |
-
static JSONObject |
-JSONML.toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
static JSONObject |
-HTTP.toJSONObject(java.lang.String string)
-Convert an HTTP header string into a JSONObject.
- |
-
static JSONObject |
-CookieList.toJSONObject(java.lang.String string)
-Convert a cookie list into a JSONObject.
- |
-
static JSONObject |
-Cookie.toJSONObject(java.lang.String string)
-Convert a cookie specification string into a JSONObject.
- |
-
static JSONObject |
-JSONML.toJSONObject(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
static java.util.Properties |
-Property.toProperties(JSONObject jo)
-Converts the JSONObject into a property file object.
- |
-
java.lang.String |
-JSONObject.toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONObject.
- |
-
java.lang.String |
-JSONArray.toString(int indentFactor)
-Make a prettyprinted JSON text of this JSONArray.
- |
-
static java.lang.String |
-JSONML.toString(JSONArray ja)
-Reverse the JSONML transformation, making an XML text from a JSONArray.
- |
-
static java.lang.String |
-CDL.toString(JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects.
- |
-
static java.lang.String |
-CDL.toString(JSONArray names,
- JSONArray ja)
-Produce a comma delimited text from a JSONArray of JSONObjects using
- a provided list of names.
- |
-
static java.lang.String |
-JSONML.toString(JSONObject jo)
-Reverse the JSONML transformation, making an XML text from a JSONObject.
- |
-
static java.lang.String |
-HTTP.toString(JSONObject jo)
-Convert a JSONObject into an HTTP header.
- |
-
static java.lang.String |
-CookieList.toString(JSONObject jo)
-Convert a JSONObject into a cookie list.
- |
-
static java.lang.String |
-Cookie.toString(JSONObject jo)
-Convert a JSONObject into a cookie specification string.
- |
-
static java.lang.String |
-XML.toString(java.lang.Object object)
-Convert a JSONObject into a well-formed, element-normal XML string.
- |
-
static java.lang.String |
-XML.toString(java.lang.Object object,
- java.lang.String tagName)
-Convert a JSONObject into a well-formed, element-normal XML string.
- |
-
JSONWriter |
-JSONWriter.value(boolean b)
-Append either the value
-true or the value
- false. |
-
JSONWriter |
-JSONWriter.value(double d)
-Append a double value.
- |
-
JSONWriter |
-JSONWriter.value(long l)
-Append a long value.
- |
-
JSONWriter |
-JSONWriter.value(java.lang.Object object)
-Append an object value.
- |
-
static java.lang.String |
-JSONObject.valueToString(java.lang.Object value)
-Make a JSON text of an Object value.
- |
-
java.io.Writer |
-JSONObject.write(java.io.Writer writer)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
java.io.Writer |
-JSONArray.write(java.io.Writer writer)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
java.io.Writer |
-JSONObject.write(java.io.Writer writer,
- int indentFactor,
- int indent)
-Write the contents of the JSONObject as JSON text to a writer.
- |
-
java.io.Writer |
-JSONArray.write(java.io.Writer writer,
- int indentFactor,
- int indent)
-Write the contents of the JSONArray as JSON text to a writer.
- |
-
| Constructor and Description | -
|---|
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONArray(java.lang.Object array)
-Construct a JSONArray from an array
- |
-
JSONArray(java.lang.String source)
-Construct a JSONArray from a source JSON text.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
JSONObject(java.lang.String source)
-Construct a JSONObject from a source JSON text string.
- |
-
JSONObject(java.lang.String baseName,
- java.util.Locale locale)
-Construct a JSONObject from a ResourceBundle.
- |
-
JSONTokener(java.io.InputStream inputStream)
-Construct a JSONTokener from an InputStream.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONML.html b/org/json/class-use/JSONML.html deleted file mode 100644 index 554f55a..0000000 --- a/org/json/class-use/JSONML.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONObject.html b/org/json/class-use/JSONObject.html deleted file mode 100644 index 348d7e3..0000000 --- a/org/json/class-use/JSONObject.html +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - -| Modifier and Type | -Method and Description | -
|---|---|
JSONObject |
-JSONObject.accumulate(java.lang.String key,
- java.lang.Object value)
-Accumulate values under a key.
- |
-
JSONObject |
-JSONObject.append(java.lang.String key,
- java.lang.Object value)
-Append values to the array under a key.
- |
-
JSONObject |
-JSONArray.getJSONObject(int index)
-Get the JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.getJSONObject(java.lang.String key)
-Get the JSONObject value associated with a key.
- |
-
JSONObject |
-JSONObject.increment(java.lang.String key)
-Increment a property of a JSONObject.
- |
-
JSONObject |
-JSONArray.optJSONObject(int index)
-Get the optional JSONObject associated with an index.
- |
-
JSONObject |
-JSONObject.optJSONObject(java.lang.String key)
-Get an optional JSONObject associated with a key.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- boolean value)
-Put a key/boolean pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.util.Collection<?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONArray which is produced from a Collection.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- double value)
-Put a key/double pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- int value)
-Put a key/int pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- long value)
-Put a key/long pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.util.Map<?,?> value)
-Put a key/value pair in the JSONObject, where the value will be a
- JSONObject which is produced from a Map.
- |
-
JSONObject |
-JSONObject.put(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject.
- |
-
JSONObject |
-JSONObject.putOnce(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null, and only if there is not already a member with that
- name.
- |
-
JSONObject |
-JSONObject.putOpt(java.lang.String key,
- java.lang.Object value)
-Put a key/value pair in the JSONObject, but only if the key and the value
- are both non-null.
- |
-
static JSONObject |
-CDL.rowToJSONObject(JSONArray names,
- JSONTokener x)
-Produce a JSONObject from a row of comma delimited text, using a
- parallel JSONArray of strings to provides the names of the elements.
- |
-
JSONObject |
-JSONArray.toJSONObject(JSONArray names)
-Produce a JSONObject by combining a JSONArray of names with the values of
- this JSONArray.
- |
-
static JSONObject |
-Property.toJSONObject(java.util.Properties properties)
-Converts a property file object into a JSONObject.
- |
-
static JSONObject |
-XML.toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject.
- |
-
static JSONObject |
-JSONML.toJSONObject(java.lang.String string)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
static JSONObject |
-HTTP.toJSONObject(java.lang.String string)
-Convert an HTTP header string into a JSONObject.
- |
-
static JSONObject |
-CookieList.toJSONObject(java.lang.String string)
-Convert a cookie list into a JSONObject.
- |
-
static JSONObject |
-Cookie.toJSONObject(java.lang.String string)
-Convert a cookie specification string into a JSONObject.
- |
-
static JSONObject |
-JSONML.toJSONObject(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
static java.lang.String[] |
-JSONObject.getNames(JSONObject jo)
-Get an array of field names from a JSONObject.
- |
-
static java.util.Properties |
-Property.toProperties(JSONObject jo)
-Converts the JSONObject into a property file object.
- |
-
static java.lang.String |
-JSONML.toString(JSONObject jo)
-Reverse the JSONML transformation, making an XML text from a JSONObject.
- |
-
static java.lang.String |
-HTTP.toString(JSONObject jo)
-Convert a JSONObject into an HTTP header.
- |
-
static java.lang.String |
-CookieList.toString(JSONObject jo)
-Convert a JSONObject into a cookie list.
- |
-
static java.lang.String |
-Cookie.toString(JSONObject jo)
-Convert a JSONObject into a cookie specification string.
- |
-
| Constructor and Description | -
|---|
JSONObject(JSONObject jo,
- java.lang.String[] names)
-Construct a JSONObject from a subset of another JSONObject.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONString.html b/org/json/class-use/JSONString.html deleted file mode 100644 index a7bbb36..0000000 --- a/org/json/class-use/JSONString.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONStringer.html b/org/json/class-use/JSONStringer.html deleted file mode 100644 index 7a563e6..0000000 --- a/org/json/class-use/JSONStringer.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONTokener.html b/org/json/class-use/JSONTokener.html deleted file mode 100644 index a659531..0000000 --- a/org/json/class-use/JSONTokener.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -| Modifier and Type | -Class and Description | -
|---|---|
class |
-HTTPTokener
-The HTTPTokener extends the JSONTokener to provide additional methods
- for the parsing of HTTP headers.
- |
-
class |
-XMLTokener
-The XMLTokener extends the JSONTokener to provide additional methods
- for the parsing of XML texts.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
static JSONArray |
-CDL.rowToJSONArray(JSONTokener x)
-Produce a JSONArray of strings from a row of comma delimited values.
- |
-
static JSONObject |
-CDL.rowToJSONObject(JSONArray names,
- JSONTokener x)
-Produce a JSONObject from a row of comma delimited text, using a
- parallel JSONArray of strings to provides the names of the elements.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONArray names,
- JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string
- using a supplied JSONArray as the source of element names.
- |
-
static JSONArray |
-CDL.toJSONArray(JSONTokener x)
-Produce a JSONArray of JSONObjects from a comma delimited text string,
- using the first row as a source of names.
- |
-
| Constructor and Description | -
|---|
JSONArray(JSONTokener x)
-Construct a JSONArray from a JSONTokener.
- |
-
JSONObject(JSONTokener x)
-Construct a JSONObject from a JSONTokener.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/JSONWriter.html b/org/json/class-use/JSONWriter.html deleted file mode 100644 index c478365..0000000 --- a/org/json/class-use/JSONWriter.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -| Modifier and Type | -Class and Description | -
|---|---|
class |
-JSONStringer
-JSONStringer provides a quick and convenient way of producing JSON text.
- |
-
| Modifier and Type | -Method and Description | -
|---|---|
JSONWriter |
-JSONWriter.array()
-Begin appending a new array.
- |
-
JSONWriter |
-JSONWriter.endArray()
-End an array.
- |
-
JSONWriter |
-JSONWriter.endObject()
-End an object.
- |
-
JSONWriter |
-JSONWriter.key(java.lang.String string)
-Append a key.
- |
-
JSONWriter |
-JSONWriter.object()
-Begin appending a new object.
- |
-
JSONWriter |
-JSONWriter.value(boolean b)
-Append either the value
-true or the value
- false. |
-
JSONWriter |
-JSONWriter.value(double d)
-Append a double value.
- |
-
JSONWriter |
-JSONWriter.value(long l)
-Append a long value.
- |
-
JSONWriter |
-JSONWriter.value(java.lang.Object object)
-Append an object value.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/Property.html b/org/json/class-use/Property.html deleted file mode 100644 index 3396dde..0000000 --- a/org/json/class-use/Property.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/XML.html b/org/json/class-use/XML.html deleted file mode 100644 index 93ef77c..0000000 --- a/org/json/class-use/XML.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/class-use/XMLTokener.html b/org/json/class-use/XMLTokener.html deleted file mode 100644 index 86648f4..0000000 --- a/org/json/class-use/XMLTokener.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - -| Modifier and Type | -Method and Description | -
|---|---|
static JSONArray |
-JSONML.toJSONArray(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONArray using the JsonML transform.
- |
-
static JSONObject |
-JSONML.toJSONObject(XMLTokener x)
-Convert a well-formed (but not necessarily valid) XML string into a
- JSONObject using the JsonML transform.
- |
-
Copyright © 2016. All Rights Reserved.
- - diff --git a/org/json/package-use.html b/org/json/package-use.html deleted file mode 100644 index 038a452..0000000 --- a/org/json/package-use.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - -| Class and Description | -
|---|
| JSONArray
- A JSONArray is an ordered sequence of values.
- |
-
| JSONException
- The JSONException is thrown by the JSON.org classes when things are amiss.
- |
-
| JSONObject
- A JSONObject is an unordered collection of name/value pairs.
- |
-
| JSONTokener
- A JSONTokener takes a source string and extracts characters and tokens from
- it.
- |
-
| JSONWriter
- JSONWriter provides a quick and convenient way of producing JSON text.
- |
-
| XMLTokener
- The XMLTokener extends the JSONTokener to provide additional methods
- for the parsing of XML texts.
- |
-
Copyright © 2016. All Rights Reserved.
- -