From f807731ca2857dfd03897d69ecd481037f346f13 Mon Sep 17 00:00:00 2001 From: stleary Date: Tue, 6 Oct 2020 15:23:44 -0500 Subject: [PATCH] latest --- allclasses-frame.html | 2 +- allclasses-noframe.html | 2 +- constant-values.html | 2 +- deprecated-list.html | 2 +- help-doc.html | 2 +- index-all.html | 2 +- index.html | 2 +- org/json/CDL.html | 522 +++++ org/json/Cookie.html | 381 ++++ org/json/CookieList.html | 315 +++ org/json/HTTP.html | 388 ++++ org/json/HTTPTokener.html | 298 +++ org/json/JSONArray.html | 2358 ++++++++++++++++++++++ org/json/JSONException.html | 316 +++ org/json/JSONML.html | 592 ++++++ org/json/JSONObject.html | 2755 ++++++++++++++++++++++++++ org/json/JSONPointer.Builder.html | 334 ++++ org/json/JSONPointer.html | 414 ++++ org/json/JSONPointerException.html | 284 +++ org/json/JSONPropertyIgnore.html | 162 ++ org/json/JSONPropertyName.html | 214 ++ org/json/JSONString.html | 232 +++ org/json/JSONStringer.html | 336 ++++ org/json/JSONTokener.html | 705 +++++++ org/json/JSONWriter.html | 622 ++++++ org/json/Property.html | 305 +++ org/json/XML.html | 902 +++++++++ org/json/XMLParserConfiguration.html | 657 ++++++ org/json/XMLTokener.html | 494 +++++ org/json/XMLXsiTypeConverter.html | 255 +++ org/json/package-frame.html | 51 + org/json/package-summary.html | 314 +++ org/json/package-tree.html | 178 ++ overview-tree.html | 2 +- serialized-form.html | 2 +- 35 files changed, 14393 insertions(+), 9 deletions(-) create mode 100644 org/json/CDL.html create mode 100644 org/json/Cookie.html create mode 100644 org/json/CookieList.html create mode 100644 org/json/HTTP.html create mode 100644 org/json/HTTPTokener.html create mode 100644 org/json/JSONArray.html create mode 100644 org/json/JSONException.html create mode 100644 org/json/JSONML.html create mode 100644 org/json/JSONObject.html create mode 100644 org/json/JSONPointer.Builder.html create mode 100644 org/json/JSONPointer.html create mode 100644 org/json/JSONPointerException.html create mode 100644 org/json/JSONPropertyIgnore.html create mode 100644 org/json/JSONPropertyName.html create mode 100644 org/json/JSONString.html create mode 100644 org/json/JSONStringer.html create mode 100644 org/json/JSONTokener.html create mode 100644 org/json/JSONWriter.html create mode 100644 org/json/Property.html create mode 100644 org/json/XML.html create mode 100644 org/json/XMLParserConfiguration.html create mode 100644 org/json/XMLTokener.html create mode 100644 org/json/XMLXsiTypeConverter.html create mode 100644 org/json/package-frame.html create mode 100644 org/json/package-summary.html create mode 100644 org/json/package-tree.html diff --git a/allclasses-frame.html b/allclasses-frame.html index bcf41c4..22a46bf 100644 --- a/allclasses-frame.html +++ b/allclasses-frame.html @@ -2,7 +2,7 @@ - + All Classes diff --git a/allclasses-noframe.html b/allclasses-noframe.html index f6aef55..e772035 100644 --- a/allclasses-noframe.html +++ b/allclasses-noframe.html @@ -2,7 +2,7 @@ - + All Classes diff --git a/constant-values.html b/constant-values.html index f7f4adc..f8ec4cb 100644 --- a/constant-values.html +++ b/constant-values.html @@ -2,7 +2,7 @@ - + Constant Field Values diff --git a/deprecated-list.html b/deprecated-list.html index 61b9a2a..d93ccd8 100644 --- a/deprecated-list.html +++ b/deprecated-list.html @@ -2,7 +2,7 @@ - + Deprecated List diff --git a/help-doc.html b/help-doc.html index 0b6c62f..fb2970b 100644 --- a/help-doc.html +++ b/help-doc.html @@ -2,7 +2,7 @@ - + API Help diff --git a/index-all.html b/index-all.html index 7b31a59..28a4a9f 100644 --- a/index-all.html +++ b/index-all.html @@ -2,7 +2,7 @@ - + Index diff --git a/index.html b/index.html index 1f4eb87..df9b85f 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - + Generated Documentation (Untitled) + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class CDL

+
+
+ +
+
    +
  • +
    +
    +
    public class CDL
    +extends Object
    +
    This provides static methods to convert comma delimited text into a + JSONArray, and to convert a JSONArray into comma delimited text. Comma + delimited text is a very popular format for data interchange. It is + understood by most database, spreadsheet, and organizer programs. +

    + 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.

    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CDL

        +
        public CDL()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        rowToJSONArray

        +
        public static JSONArray rowToJSONArray(JSONTokener x)
        +                                throws JSONException
        +
        Produce a JSONArray of strings from a row of comma delimited values.
        +
        +
        Parameters:
        +
        x - A JSONTokener of the source text.
        +
        Returns:
        +
        A JSONArray of strings.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        rowToJSONObject

        +
        public static JSONObject rowToJSONObject(JSONArray names,
        +                                         JSONTokener x)
        +                                  throws JSONException
        +
        Produce a JSONObject from a row of comma delimited text, using a + parallel JSONArray of strings to provides the names of the elements.
        +
        +
        Parameters:
        +
        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.
        +
        Returns:
        +
        A JSONObject combining the names and values.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        rowToString

        +
        public static String rowToString(JSONArray ja)
        +
        Produce a comma delimited text row from a JSONArray. Values containing + the comma character will be quoted. Troublesome characters may be + removed.
        +
        +
        Parameters:
        +
        ja - A JSONArray of strings.
        +
        Returns:
        +
        A string ending in NEWLINE.
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(String string)
        +                             throws JSONException
        +
        Produce a JSONArray of JSONObjects from a comma delimited text string, + using the first row as a source of names.
        +
        +
        Parameters:
        +
        string - The comma delimited text.
        +
        Returns:
        +
        A JSONArray of JSONObjects.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(JSONTokener x)
        +                             throws JSONException
        +
        Produce a JSONArray of JSONObjects from a comma delimited text string, + using the first row as a source of names.
        +
        +
        Parameters:
        +
        x - The JSONTokener containing the comma delimited text.
        +
        Returns:
        +
        A JSONArray of JSONObjects.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(JSONArray names,
        +                                    String string)
        +                             throws JSONException
        +
        Produce a JSONArray of JSONObjects from a comma delimited text string + using a supplied JSONArray as the source of element names.
        +
        +
        Parameters:
        +
        names - A JSONArray of strings.
        +
        string - The comma delimited text.
        +
        Returns:
        +
        A JSONArray of JSONObjects.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(JSONArray names,
        +                                    JSONTokener x)
        +                             throws JSONException
        +
        Produce a JSONArray of JSONObjects from a comma delimited text string + using a supplied JSONArray as the source of element names.
        +
        +
        Parameters:
        +
        names - A JSONArray of strings.
        +
        x - A JSONTokener of the source text.
        +
        Returns:
        +
        A JSONArray of JSONObjects.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONArray ja)
        +                       throws JSONException
        +
        Produce a comma delimited text from a JSONArray of JSONObjects. The + first row will be a list of names obtained by inspecting the first + JSONObject.
        +
        +
        Parameters:
        +
        ja - A JSONArray of JSONObjects.
        +
        Returns:
        +
        A comma delimited text.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONArray names,
        +                              JSONArray ja)
        +                       throws JSONException
        +
        Produce a comma delimited text from a JSONArray of JSONObjects using + a provided list of names. The list of names is not included in the + output.
        +
        +
        Parameters:
        +
        names - A JSONArray of strings.
        +
        ja - A JSONArray of JSONObjects.
        +
        Returns:
        +
        A comma delimited text.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/Cookie.html b/org/json/Cookie.html new file mode 100644 index 0000000..1dd4c87 --- /dev/null +++ b/org/json/Cookie.html @@ -0,0 +1,381 @@ + + + + + +Cookie + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class Cookie

+
+
+ +
+
    +
  • +
    +
    +
    public class Cookie
    +extends Object
    +
    Convert a web browser cookie specification to a JSONObject and back. + JSON and Cookies are both notations for name/value pairs. + See also: https://tools.ietf.org/html/rfc6265
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Cookie

        +
        public Cookie()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        escape

        +
        public static String escape(String string)
        +
        Produce a copy of a string in which the characters '+', '%', '=', ';' + and control characters are replaced with "%hh". This is a gentle form + of URL encoding, attempting to cause as little distortion to the + string as possible. The characters '=' and ';' are meta characters in + cookies. By convention, they are escaped using the URL-encoding. This is + only a convention, not a standard. Often, cookies are expected to have + encoded values. We encode '=' and ';' because we must. We encode '%' and + '+' because they are meta characters in URL encoding.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        Returns:
        +
        The escaped result.
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string)
        +
        Convert a cookie specification string into a JSONObject. The string + must contain a name value pair separated by '='. The name and the value + will be unescaped, possibly converting '+' and '%' sequences. The + cookie properties may follow, separated by ';', also represented as + name=value (except the Attribute properties like "Secure" or "HttpOnly", + which do not have a value. The value 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.
        +
        +
        Parameters:
        +
        string - The cookie specification string.
        +
        Returns:
        +
        A JSONObject containing "name", "value", and possibly other + members.
        +
        Throws:
        +
        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.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONObject jo)
        +                       throws JSONException
        +
        Convert a JSONObject into a cookie specification string. The JSONObject + must contain "name" and "value" members (case insensitive). + If the JSONObject contains other members, they will be appended to the cookie + specification string. User-Agents are instructed to ignore unknown attributes, + so ensure your JSONObject is using only known attributes. + See also: https://tools.ietf.org/html/rfc6265
        +
        +
        Parameters:
        +
        jo - A JSONObject
        +
        Returns:
        +
        A cookie specification string
        +
        Throws:
        +
        JSONException - thrown if the cookie has no name.
        +
        +
      • +
      + + + +
        +
      • +

        unescape

        +
        public static String unescape(String string)
        +
        Convert %hh sequences to single characters, and + convert plus to space.
        +
        +
        Parameters:
        +
        string - A string that may contain + + (plus) and + %hh sequences.
        +
        Returns:
        +
        The unescaped string.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/CookieList.html b/org/json/CookieList.html new file mode 100644 index 0000000..c33cfb0 --- /dev/null +++ b/org/json/CookieList.html @@ -0,0 +1,315 @@ + + + + + +CookieList + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class CookieList

+
+
+ +
+
    +
  • +
    +
    +
    public class CookieList
    +extends Object
    +
    Convert a web browser cookie list string to a JSONObject and back.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CookieList

        +
        public CookieList()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string)
        +                               throws JSONException
        +
        Convert a cookie list into a JSONObject. A cookie list is a sequence + of name/value pairs. The names are separated from the values by '='. + The pairs are separated by ';'. The names and the values + will be unescaped, possibly converting '+' and '%' sequences. + + To add a cookie to a cookie list, + cookielistJSONObject.put(cookieJSONObject.getString("name"), + cookieJSONObject.getString("value"));
        +
        +
        Parameters:
        +
        string - A cookie list string
        +
        Returns:
        +
        A JSONObject
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONObject jo)
        +                       throws JSONException
        +
        Convert a JSONObject into a cookie list. A cookie list is a sequence + of name/value pairs. The names are separated from the values by '='. + The pairs are separated by ';'. The characters '%', '+', '=', and ';' + in the names and values are replaced by "%hh".
        +
        +
        Parameters:
        +
        jo - A JSONObject
        +
        Returns:
        +
        A cookie list string
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/HTTP.html b/org/json/HTTP.html new file mode 100644 index 0000000..8c5b1b3 --- /dev/null +++ b/org/json/HTTP.html @@ -0,0 +1,388 @@ + + + + + +HTTP + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class HTTP

+
+
+ +
+
    +
  • +
    +
    +
    public class HTTP
    +extends Object
    +
    Convert an HTTP header to a JSONObject and back.
    +
  • +
+
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        HTTP

        +
        public HTTP()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string)
        +                               throws JSONException
        +
        Convert an HTTP header string into a JSONObject. It can be a request + header or a response header. A request header will contain +
        {
        +    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.
        +
        +
        Parameters:
        +
        string - An HTTP header string.
        +
        Returns:
        +
        A JSONObject containing the elements and attributes + of the XML string.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONObject jo)
        +                       throws JSONException
        +
        Convert a JSONObject into an HTTP header. A request header must contain +
        {
        +    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.
        +
        +
        Parameters:
        +
        jo - A JSONObject
        +
        Returns:
        +
        An HTTP header string.
        +
        Throws:
        +
        JSONException - if the object does not contain enough + information.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/HTTPTokener.html b/org/json/HTTPTokener.html new file mode 100644 index 0000000..36dfd63 --- /dev/null +++ b/org/json/HTTPTokener.html @@ -0,0 +1,298 @@ + + + + + +HTTPTokener + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class HTTPTokener

+
+
+ +
+
    +
  • +
    +
    +
    public class HTTPTokener
    +extends JSONTokener
    +
    The HTTPTokener extends the JSONTokener to provide additional methods + for the parsing of HTTP headers.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        HTTPTokener

        +
        public HTTPTokener(String string)
        +
        Construct an HTTPTokener from a string.
        +
        +
        Parameters:
        +
        string - A source string.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        nextToken

        +
        public String nextToken()
        +                 throws JSONException
        +
        Get the next token or string. This is used in parsing HTTP headers.
        +
        +
        Returns:
        +
        A String.
        +
        Throws:
        +
        JSONException - if a syntax error occurs
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONArray.html b/org/json/JSONArray.html new file mode 100644 index 0000000..671158d --- /dev/null +++ b/org/json/JSONArray.html @@ -0,0 +1,2358 @@ + + + + + +JSONArray + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONArray

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Iterable<Object>
    +
    +
    +
    +
    public class JSONArray
    +extends Object
    +implements Iterable<Object>
    +
    A JSONArray is an ordered sequence of values. Its external text form is a + string wrapped in square brackets with commas separating the values. The + internal form is an object having 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: +

      +
    • An extra , (comma) may appear just + before the closing bracket.
    • +
    • The null value will be inserted when there is , +  (comma) elision.
    • +
    • Strings may be quoted with ' (single + quote).
    • +
    • Strings do not need to be quoted at all if they do not begin with a quote + or single quote, and if they do not contain leading or trailing spaces, and + if they do not contain any of these characters: + { } [ ] / \ : , # and if they do not look like numbers and + if they are not the reserved words true, false, or + null.
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      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.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      Objectget(int index) +
      Get the object value associated with an index.
      +
      BigDecimalgetBigDecimal(int index) +
      Get the BigDecimal value associated with an index.
      +
      BigIntegergetBigInteger(int index) +
      Get the BigInteger value associated with an index.
      +
      booleangetBoolean(int index) +
      Get the boolean value associated with an index.
      +
      doublegetDouble(int index) +
      Get the double value associated with an index.
      +
      <E extends Enum<E>>
      E
      getEnum(Class<E> clazz, + int index) +
      Get the enum value associated with an index.
      +
      floatgetFloat(int index) +
      Get the float value associated with a key.
      +
      intgetInt(int index) +
      Get the int value associated with an index.
      +
      JSONArraygetJSONArray(int index) +
      Get the JSONArray associated with an index.
      +
      JSONObjectgetJSONObject(int index) +
      Get the JSONObject associated with an index.
      +
      longgetLong(int index) +
      Get the long value associated with an index.
      +
      NumbergetNumber(int index) +
      Get the Number value associated with a key.
      +
      StringgetString(int index) +
      Get the string associated with an index.
      +
      booleanisEmpty() +
      Check if JSONArray is empty.
      +
      booleanisNull(int index) +
      Determine if the value is null.
      +
      Iterator<Object>iterator() 
      Stringjoin(String separator) +
      Make a string from the contents of this JSONArray.
      +
      intlength() +
      Get the number of elements in the JSONArray, included nulls.
      +
      Objectopt(int index) +
      Get the optional object value associated with an index.
      +
      BigDecimaloptBigDecimal(int index, + BigDecimal defaultValue) +
      Get the optional BigDecimal value associated with an index.
      +
      BigIntegeroptBigInteger(int index, + BigInteger defaultValue) +
      Get the optional BigInteger value associated with an index.
      +
      booleanoptBoolean(int index) +
      Get the optional boolean value associated with an index.
      +
      booleanoptBoolean(int index, + boolean defaultValue) +
      Get the optional boolean value associated with an index.
      +
      doubleoptDouble(int index) +
      Get the optional double value associated with an index.
      +
      doubleoptDouble(int index, + double defaultValue) +
      Get the optional double value associated with an index.
      +
      <E extends Enum<E>>
      E
      optEnum(Class<E> clazz, + int index) +
      Get the enum value associated with a key.
      +
      <E extends Enum<E>>
      E
      optEnum(Class<E> clazz, + int index, + E defaultValue) +
      Get the enum value associated with a key.
      +
      floatoptFloat(int index) +
      Get the optional float value associated with an index.
      +
      floatoptFloat(int index, + float defaultValue) +
      Get the optional float value associated with an index.
      +
      intoptInt(int index) +
      Get the optional int value associated with an index.
      +
      intoptInt(int index, + int defaultValue) +
      Get the optional int value associated with an index.
      +
      JSONArrayoptJSONArray(int index) +
      Get the optional JSONArray associated with an index.
      +
      JSONObjectoptJSONObject(int index) +
      Get the optional JSONObject associated with an index.
      +
      longoptLong(int index) +
      Get the optional long value associated with an index.
      +
      longoptLong(int index, + long defaultValue) +
      Get the optional long value associated with an index.
      +
      NumberoptNumber(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.
      +
      NumberoptNumber(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.
      +
      ObjectoptQuery(JSONPointer jsonPointer) +
      Queries and returns a value from this object using jsonPointer, or + returns null if the query fails due to a missing key.
      +
      ObjectoptQuery(String jsonPointer) +
      Queries and returns a value from this object using jsonPointer, or + returns null if the query fails due to a missing key.
      +
      StringoptString(int index) +
      Get the optional string value associated with an index.
      +
      StringoptString(int index, + String defaultValue) +
      Get the optional string associated with an index.
      +
      JSONArrayput(boolean value) +
      Append a boolean value.
      +
      JSONArrayput(Collection<?> value) +
      Put a value in the JSONArray, where the value will be a JSONArray which + is produced from a Collection.
      +
      JSONArrayput(double value) +
      Append a double value.
      +
      JSONArrayput(float value) +
      Append a float value.
      +
      JSONArrayput(int value) +
      Append an int value.
      +
      JSONArrayput(int index, + boolean value) +
      Put or replace a boolean value in the JSONArray.
      +
      JSONArrayput(int index, + Collection<?> value) +
      Put a value in the JSONArray, where the value will be a JSONArray which + is produced from a Collection.
      +
      JSONArrayput(int index, + double value) +
      Put or replace a double value.
      +
      JSONArrayput(int index, + float value) +
      Put or replace a float value.
      +
      JSONArrayput(int index, + int value) +
      Put or replace an int value.
      +
      JSONArrayput(int index, + long value) +
      Put or replace a long value.
      +
      JSONArrayput(int index, + Map<?,?> value) +
      Put a value in the JSONArray, where the value will be a JSONObject that + is produced from a Map.
      +
      JSONArrayput(int index, + Object value) +
      Put or replace an object value in the JSONArray.
      +
      JSONArrayput(long value) +
      Append an long value.
      +
      JSONArrayput(Map<?,?> value) +
      Put a value in the JSONArray, where the value will be a JSONObject which + is produced from a Map.
      +
      JSONArrayput(Object value) +
      Append an object value.
      +
      JSONArrayputAll(Collection<?> collection) +
      Put a collection's elements in to the JSONArray.
      +
      JSONArrayputAll(Iterable<?> iter) +
      Put an Iterable's elements in to the JSONArray.
      +
      JSONArrayputAll(JSONArray array) +
      Put a JSONArray's elements in to the JSONArray.
      +
      JSONArrayputAll(Object array) +
      Put an array's elements in to the JSONArray.
      +
      Objectquery(JSONPointer jsonPointer) +
      Uses a user initialized JSONPointer and tries to + match it to an item within this JSONArray.
      +
      Objectquery(String jsonPointer) +
      Creates a JSONPointer using an initialization string and tries to + match it to an item within this JSONArray.
      +
      Objectremove(int index) +
      Remove an index and close the hole.
      +
      booleansimilar(Object other) +
      Determine if two JSONArrays are similar.
      +
      JSONObjecttoJSONObject(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.
      +
      StringtoString() +
      Make a JSON text of this JSONArray.
      +
      StringtoString(int indentFactor) +
      Make a pretty-printed JSON text of this JSONArray.
      +
      Writerwrite(Writer writer) +
      Write the contents of the JSONArray as JSON text to a writer.
      +
      Writerwrite(Writer writer, + int indentFactor, + int indent) +
      Write the contents of the JSONArray as JSON text to a writer.
      +
      + + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray()
        +
        Construct an empty JSONArray.
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(JSONTokener x)
        +          throws JSONException
        +
        Construct a JSONArray from a JSONTokener.
        +
        +
        Parameters:
        +
        x - A JSONTokener
        +
        Throws:
        +
        JSONException - If there is a syntax error.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(String source)
        +          throws JSONException
        +
        Construct a JSONArray from a source JSON text.
        +
        +
        Parameters:
        +
        source - A string that begins with [ (left + bracket) and ends with ] +  (right bracket).
        +
        Throws:
        +
        JSONException - If there is a syntax error.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(Collection<?> collection)
        +
        Construct a JSONArray from a Collection.
        +
        +
        Parameters:
        +
        collection - A Collection.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(Iterable<?> iter)
        +
        Construct a JSONArray from an Iterable. This is a shallow copy.
        +
        +
        Parameters:
        +
        iter - A Iterable collection.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(JSONArray array)
        +
        Construct a JSONArray from another JSONArray. This is a shallow copy.
        +
        +
        Parameters:
        +
        array - A array.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(Object array)
        +          throws JSONException
        +
        Construct a JSONArray from an array.
        +
        +
        Parameters:
        +
        array - Array. If the parameter passed is null, or not an array, an + exception will be thrown.
        +
        Throws:
        +
        JSONException - If not an array or if an array value is non-finite number.
        +
        NullPointerException - Thrown if the array parameter is null.
        +
        +
      • +
      + + + +
        +
      • +

        JSONArray

        +
        public JSONArray(int initialCapacity)
        +          throws JSONException
        +
        Construct a JSONArray with the specified initial capacity.
        +
        +
        Parameters:
        +
        initialCapacity - the initial capacity of the JSONArray.
        +
        Throws:
        +
        JSONException - If the initial capacity is negative.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + + + + + +
        +
      • +

        get

        +
        public Object get(int index)
        +           throws JSONException
        +
        Get the object value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        An object value.
        +
        Throws:
        +
        JSONException - If there is no value for the index.
        +
        +
      • +
      + + + +
        +
      • +

        getBoolean

        +
        public boolean getBoolean(int index)
        +                   throws JSONException
        +
        Get the boolean value associated with an index. The string values "true" + and "false" are converted to boolean.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The truth.
        +
        Throws:
        +
        JSONException - If there is no value for the index or if the value is not + convertible to boolean.
        +
        +
      • +
      + + + +
        +
      • +

        getDouble

        +
        public double getDouble(int index)
        +                 throws JSONException
        +
        Get the double value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        Throws:
        +
        JSONException - If the key is not found or if the value cannot be converted + to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getFloat

        +
        public float getFloat(int index)
        +               throws JSONException
        +
        Get the float value associated with a key.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a Number + object and cannot be converted to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getNumber

        +
        public Number getNumber(int index)
        +                 throws JSONException
        +
        Get the Number value associated with a key.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a Number + object and cannot be converted to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getEnum

        +
        public <E extends Enum<E>> E getEnum(Class<E> clazz,
        +                                     int index)
        +                              throws JSONException
        +
        Get the enum value associated with an index.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        clazz - The type of enum to retrieve.
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The enum value at the index location
        +
        Throws:
        +
        JSONException - if the key is not found or if the value cannot be converted + to an enum.
        +
        +
      • +
      + + + +
        +
      • +

        getBigDecimal

        +
        public BigDecimal getBigDecimal(int index)
        +                         throws JSONException
        +
        Get the BigDecimal value associated with an index. If the value is float + or double, the the BigDecimal.BigDecimal(double) constructor + will be used. See notes on the constructor for conversion issues that + may arise.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        Throws:
        +
        JSONException - If the key is not found or if the value cannot be converted + to a BigDecimal.
        +
        +
      • +
      + + + +
        +
      • +

        getBigInteger

        +
        public BigInteger getBigInteger(int index)
        +                         throws JSONException
        +
        Get the BigInteger value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        Throws:
        +
        JSONException - If the key is not found or if the value cannot be converted + to a BigInteger.
        +
        +
      • +
      + + + +
        +
      • +

        getInt

        +
        public int getInt(int index)
        +           throws JSONException
        +
        Get the int value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        Throws:
        +
        JSONException - If the key is not found or if the value is not a number.
        +
        +
      • +
      + + + +
        +
      • +

        getJSONArray

        +
        public JSONArray getJSONArray(int index)
        +                       throws JSONException
        +
        Get the JSONArray associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        A JSONArray value.
        +
        Throws:
        +
        JSONException - If there is no value for the index. or if the value is not a + JSONArray
        +
        +
      • +
      + + + +
        +
      • +

        getJSONObject

        +
        public JSONObject getJSONObject(int index)
        +                         throws JSONException
        +
        Get the JSONObject associated with an index.
        +
        +
        Parameters:
        +
        index - subscript
        +
        Returns:
        +
        A JSONObject value.
        +
        Throws:
        +
        JSONException - If there is no value for the index or if the value is not a + JSONObject
        +
        +
      • +
      + + + +
        +
      • +

        getLong

        +
        public long getLong(int index)
        +             throws JSONException
        +
        Get the long value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        Throws:
        +
        JSONException - If the key is not found or if the value cannot be converted + to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getString

        +
        public String getString(int index)
        +                 throws JSONException
        +
        Get the string associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        A string value.
        +
        Throws:
        +
        JSONException - If there is no string value for the index.
        +
        +
      • +
      + + + +
        +
      • +

        isNull

        +
        public boolean isNull(int index)
        +
        Determine if the value is null.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        true if the value at the index is null, or if there is no value.
        +
        +
      • +
      + + + +
        +
      • +

        join

        +
        public String join(String separator)
        +            throws JSONException
        +
        Make a string from the contents of this JSONArray. The + separator string is inserted between each element. Warning: + This method assumes that the data structure is acyclical.
        +
        +
        Parameters:
        +
        separator - A string that will be inserted between the elements.
        +
        Returns:
        +
        a string.
        +
        Throws:
        +
        JSONException - If the array contains an invalid number.
        +
        +
      • +
      + + + +
        +
      • +

        length

        +
        public int length()
        +
        Get the number of elements in the JSONArray, included nulls.
        +
        +
        Returns:
        +
        The length (or size).
        +
        +
      • +
      + + + +
        +
      • +

        opt

        +
        public Object opt(int index)
        +
        Get the optional object value associated with an index.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1. If not, null is returned.
        +
        Returns:
        +
        An object value, or null if there is no object at that index.
        +
        +
      • +
      + + + +
        +
      • +

        optBoolean

        +
        public boolean optBoolean(int index)
        +
        Get the optional boolean value associated with an index. It returns false + if there is no value at that index, or if the value is not Boolean.TRUE + or the String "true".
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The truth.
        +
        +
      • +
      + + + +
        +
      • +

        optBoolean

        +
        public boolean optBoolean(int index,
        +                          boolean defaultValue)
        +
        Get the optional boolean value associated with an index. It returns the + defaultValue if there is no value at that index or if it is not a Boolean + or the String "true" or "false" (case insensitive).
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - A boolean default.
        +
        Returns:
        +
        The truth.
        +
        +
      • +
      + + + +
        +
      • +

        optDouble

        +
        public double optDouble(int index)
        +
        Get the optional double value associated with an index. NaN is returned + if there is no value for the index, or if the value is not a number and + cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optDouble

        +
        public double optDouble(int index,
        +                        double defaultValue)
        +
        Get the optional double value associated with an index. The defaultValue + is returned if there is no value for the index, or if the value is not a + number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - subscript
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optFloat

        +
        public float optFloat(int index)
        +
        Get the optional float value associated with an index. NaN is returned + if there is no value for the index, or if the value is not a number and + cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optFloat

        +
        public float optFloat(int index,
        +                      float defaultValue)
        +
        Get the optional float value associated with an index. The defaultValue + is returned if there is no value for the index, or if the value is not a + number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - subscript
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optInt

        +
        public int optInt(int index)
        +
        Get the optional int value associated with an index. Zero is returned if + there is no value for the index, or if the value is not a number and + cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optInt

        +
        public int optInt(int index,
        +                  int defaultValue)
        +
        Get the optional int value associated with an index. The defaultValue is + returned if there is no value for the index, or if the value is not a + number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optEnum

        +
        public <E extends Enum<E>> E optEnum(Class<E> clazz,
        +                                     int index)
        +
        Get the enum value associated with a key.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        clazz - The type of enum to retrieve.
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The enum value at the index location or null if not found
        +
        +
      • +
      + + + + + +
        +
      • +

        optEnum

        +
        public <E extends Enum<E>> E optEnum(Class<E> clazz,
        +                                     int index,
        +                                     E defaultValue)
        +
        Get the enum value associated with a key.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        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 found
        +
        Returns:
        +
        The enum value at the index location or defaultValue if + the value is not found or cannot be assigned to clazz
        +
        +
      • +
      + + + +
        +
      • +

        optBigInteger

        +
        public BigInteger optBigInteger(int index,
        +                                BigInteger defaultValue)
        +
        Get the optional BigInteger value associated with an index. The + defaultValue is returned if there is no value for the index, or if the + value is not a number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optBigDecimal

        +
        public BigDecimal optBigDecimal(int index,
        +                                BigDecimal defaultValue)
        +
        Get the optional BigDecimal value associated with an index. The + defaultValue is returned if there is no value for the index, or if the + value is not a number and cannot be converted to a number. If the value + is float or double, the the BigDecimal.BigDecimal(double) + constructor will be used. See notes on the constructor for conversion + issues that may arise.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optJSONArray

        +
        public JSONArray optJSONArray(int index)
        +
        Get the optional JSONArray associated with an index.
        +
        +
        Parameters:
        +
        index - subscript
        +
        Returns:
        +
        A JSONArray value, or null if the index has no value, or if the + value is not a JSONArray.
        +
        +
      • +
      + + + +
        +
      • +

        optJSONObject

        +
        public JSONObject optJSONObject(int index)
        +
        Get the optional JSONObject associated with an index. Null is returned if + the key is not found, or null if the index has no value, or if the value + is not a JSONObject.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        A JSONObject value.
        +
        +
      • +
      + + + +
        +
      • +

        optLong

        +
        public long optLong(int index)
        +
        Get the optional long value associated with an index. Zero is returned if + there is no value for the index, or if the value is not a number and + cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optLong

        +
        public long optLong(int index,
        +                    long defaultValue)
        +
        Get the optional long value associated with an index. The defaultValue is + returned if there is no value for the index, or if the value is not a + number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optNumber

        +
        public 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. 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.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optNumber

        +
        public 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. 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.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optString

        +
        public String optString(int index)
        +
        Get the optional string value associated with an index. It returns an + empty string if there is no value at that index. If the value is not a + string and is not null, then it is converted to a string.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        Returns:
        +
        A String value.
        +
        +
      • +
      + + + +
        +
      • +

        optString

        +
        public String optString(int index,
        +                        String defaultValue)
        +
        Get the optional string associated with an index. The defaultValue is + returned if the key is not found.
        +
        +
        Parameters:
        +
        index - The index must be between 0 and length() - 1.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        A String value.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(boolean value)
        +
        Append a boolean value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - A boolean value.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(Collection<?> value)
        +
        Put a value in the JSONArray, where the value will be a JSONArray which + is produced from a Collection.
        +
        +
        Parameters:
        +
        value - A Collection value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(double value)
        +              throws JSONException
        +
        Append a double value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - A double value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - if the value is not finite.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(float value)
        +              throws JSONException
        +
        Append a float value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - A float value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - if the value is not finite.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int value)
        +
        Append an int value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - An int value.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(long value)
        +
        Append an long value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - A long value.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(Map<?,?> value)
        +
        Put a value in the JSONArray, where the value will be a JSONObject which + is produced from a Map.
        +
        +
        Parameters:
        +
        value - A Map value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If a value in the map is non-finite number.
        +
        NullPointerException - If a key in the map is null
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(Object value)
        +
        Append an object value. This increases the array's length by one.
        +
        +
        Parameters:
        +
        value - An object value. The value should be a Boolean, Double, + Integer, JSONArray, JSONObject, Long, or String, or the + JSONObject.NULL object.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     boolean value)
        +              throws JSONException
        +
        Put or replace a boolean value in the JSONArray. If the index is greater + than the length of the JSONArray, then null elements will be added as + necessary to pad it out.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - A boolean value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     Collection<?> value)
        +              throws JSONException
        +
        Put a value in the JSONArray, where the value will be a JSONArray which + is produced from a Collection.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - A Collection value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative or if the value is non-finite.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     double value)
        +              throws JSONException
        +
        Put or replace a double value. If the index is greater than the length of + the JSONArray, then null elements will be added as necessary to pad it + out.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - A double value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative or if the value is non-finite.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     float value)
        +              throws JSONException
        +
        Put or replace a float value. If the index is greater than the length of + the JSONArray, then null elements will be added as necessary to pad it + out.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - A float value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative or if the value is non-finite.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     int value)
        +              throws JSONException
        +
        Put or replace an int value. If the index is greater than the length of + the JSONArray, then null elements will be added as necessary to pad it + out.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - An int value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     long value)
        +              throws JSONException
        +
        Put or replace a long value. If the index is greater than the length of + the JSONArray, then null elements will be added as necessary to pad it + out.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - A long value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     Map<?,?> value)
        +              throws JSONException
        +
        Put a value in the JSONArray, where the value will be a JSONObject that + is produced from a Map.
        +
        +
        Parameters:
        +
        index - The subscript.
        +
        value - The Map value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative or if the the value is an invalid + number.
        +
        NullPointerException - If a key in the map is null
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONArray put(int index,
        +                     Object value)
        +              throws JSONException
        +
        Put or replace an object value in the JSONArray. If the index is greater + than the length of the JSONArray, then null elements will be added as + necessary to pad it out.
        +
        +
        Parameters:
        +
        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.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the index is negative or if the the value is an invalid + number.
        +
        +
      • +
      + + + +
        +
      • +

        putAll

        +
        public JSONArray putAll(Collection<?> collection)
        +
        Put a collection's elements in to the JSONArray.
        +
        +
        Parameters:
        +
        collection - A Collection.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        putAll

        +
        public JSONArray putAll(Iterable<?> iter)
        +
        Put an Iterable's elements in to the JSONArray.
        +
        +
        Parameters:
        +
        iter - An Iterable.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        putAll

        +
        public JSONArray putAll(JSONArray array)
        +
        Put a JSONArray's elements in to the JSONArray.
        +
        +
        Parameters:
        +
        array - A JSONArray.
        +
        Returns:
        +
        this.
        +
        +
      • +
      + + + +
        +
      • +

        putAll

        +
        public JSONArray putAll(Object array)
        +                 throws JSONException
        +
        Put an array's elements in to the JSONArray.
        +
        +
        Parameters:
        +
        array - Array. If the parameter passed is null, or not an array or Iterable, an + exception will be thrown.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If not an array, JSONArray, Iterable or if an value is non-finite number.
        +
        NullPointerException - Thrown if the array parameter is null.
        +
        +
      • +
      + + + +
        +
      • +

        query

        +
        public Object query(String jsonPointer)
        +
        Creates a JSONPointer using an initialization string and tries to + match it to an item within this JSONArray. For example, given a + JSONArray initialized with this document: +
        + [
        +     {"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.
        +
        +
        Parameters:
        +
        jsonPointer - string that can be used to create a JSONPointer
        +
        Returns:
        +
        the item matched by the JSONPointer, otherwise null
        +
        +
      • +
      + + + +
        +
      • +

        query

        +
        public Object query(JSONPointer jsonPointer)
        +
        Uses a user initialized JSONPointer and tries to + match it to an item within this JSONArray. For example, given a + JSONArray initialized with this document: +
        + [
        +     {"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.
        +
        +
        Parameters:
        +
        jsonPointer - string that can be used to create a JSONPointer
        +
        Returns:
        +
        the item matched by the JSONPointer, otherwise null
        +
        +
      • +
      + + + +
        +
      • +

        optQuery

        +
        public 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.
        +
        +
        Parameters:
        +
        jsonPointer - the string representation of the JSON pointer
        +
        Returns:
        +
        the queried value or null
        +
        Throws:
        +
        IllegalArgumentException - if jsonPointer has invalid syntax
        +
        +
      • +
      + + + +
        +
      • +

        optQuery

        +
        public 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.
        +
        +
        Parameters:
        +
        jsonPointer - The JSON pointer
        +
        Returns:
        +
        the queried value or null
        +
        Throws:
        +
        IllegalArgumentException - if jsonPointer has invalid syntax
        +
        +
      • +
      + + + +
        +
      • +

        remove

        +
        public Object remove(int index)
        +
        Remove an index and close the hole.
        +
        +
        Parameters:
        +
        index - The index of the element to be removed.
        +
        Returns:
        +
        The value that was associated with the index, or null if there + was no value.
        +
        +
      • +
      + + + +
        +
      • +

        similar

        +
        public boolean similar(Object other)
        +
        Determine if two JSONArrays are similar. + They must contain similar sequences.
        +
        +
        Parameters:
        +
        other - The other JSONArray
        +
        Returns:
        +
        true if they are equal
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public JSONObject toJSONObject(JSONArray names)
        +                        throws JSONException
        +
        Produce a JSONObject by combining a JSONArray of names with the values of + this JSONArray.
        +
        +
        Parameters:
        +
        names - A JSONArray containing a list of key strings. These will be + paired with the values.
        +
        Returns:
        +
        A JSONObject, or null if there are no names or if this JSONArray + has no values.
        +
        Throws:
        +
        JSONException - If any of the names are null.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Make a JSON text of this JSONArray. For compactness, no unnecessary + whitespace is added. If it is not possible to produce a syntactically + correct JSON text then null will be returned instead. This could occur if + the array contains an invalid number. +

        + Warning: This method assumes that the data structure is acyclical. +

        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        +
        a printable, displayable, transmittable representation of the + array.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString(int indentFactor)
        +                throws JSONException
        +
        Make a pretty-printed JSON text of this JSONArray. + +

        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. +

        +
        +
        Parameters:
        +
        indentFactor - The number of spaces to add to each level of indentation.
        +
        Returns:
        +
        a printable, displayable, transmittable representation of the + object, beginning with [ (left + bracket) and ending with ] +  (right bracket).
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        write

        +
        public Writer write(Writer writer)
        +             throws JSONException
        +
        Write the contents of the JSONArray as JSON text to a writer. For + compactness, no whitespace is added. +

        + Warning: This method assumes that the data structure is acyclical. +

        +
        +
        Parameters:
        +
        writer - the writer object
        +
        Returns:
        +
        The writer.
        +
        Throws:
        +
        JSONException - if a called function fails
        +
        +
      • +
      + + + +
        +
      • +

        write

        +
        public Writer write(Writer writer,
        +                    int indentFactor,
        +                    int indent)
        +             throws JSONException
        +
        Write the contents of the JSONArray as JSON text to a writer. + +

        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. +

        +
        +
        Parameters:
        +
        writer - Writes the serialized JSON
        +
        indentFactor - The number of spaces to add to each level of indentation.
        +
        indent - The indentation of the top level.
        +
        Returns:
        +
        The writer.
        +
        Throws:
        +
        JSONException - if a called function fails or unable to write
        +
        +
      • +
      + + + +
        +
      • +

        toList

        +
        public List<Object> toList()
        +
        Returns a java.util.List containing all of the elements in this array. + If an element in the array is a JSONArray or JSONObject it will also + be converted to a List and a Map respectively. +

        + Warning: This method assumes that the data structure is acyclical.

        +
        +
        Returns:
        +
        a java.util.List containing the elements of this array
        +
        +
      • +
      + + + +
        +
      • +

        isEmpty

        +
        public boolean isEmpty()
        +
        Check if JSONArray is empty.
        +
        +
        Returns:
        +
        true if JSONArray is empty, otherwise false.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONException.html b/org/json/JSONException.html new file mode 100644 index 0000000..cd13ce5 --- /dev/null +++ b/org/json/JSONException.html @@ -0,0 +1,316 @@ + + + + + +JSONException + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONException

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONException

        +
        public JSONException(String message)
        +
        Constructs a JSONException with an explanatory message.
        +
        +
        Parameters:
        +
        message - Detail about the reason for the exception.
        +
        +
      • +
      + + + +
        +
      • +

        JSONException

        +
        public JSONException(String message,
        +                     Throwable cause)
        +
        Constructs a JSONException with an explanatory message and cause.
        +
        +
        Parameters:
        +
        message - Detail about the reason for the exception.
        +
        cause - The cause.
        +
        +
      • +
      + + + +
        +
      • +

        JSONException

        +
        public JSONException(Throwable cause)
        +
        Constructs a new JSONException with the specified cause.
        +
        +
        Parameters:
        +
        cause - The cause.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONML.html b/org/json/JSONML.html new file mode 100644 index 0000000..d0daa93 --- /dev/null +++ b/org/json/JSONML.html @@ -0,0 +1,592 @@ + + + + + +JSONML + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONML

+
+
+ +
+
    +
  • +
    +
    +
    public class JSONML
    +extends Object
    +
    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.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      JSONML() 
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONML

        +
        public JSONML()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(String string)
        +                             throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONArray using the JsonML transform. Each XML tag is represented as + a JSONArray in which the first element is the tag name. If the tag has + attributes, then the second element will be JSONObject containing the + name/value pairs. If the tag contains children, then strings and + JSONArrays will represent the child tags. + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        Returns:
        +
        A JSONArray containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONArray
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(String string,
        +                                    boolean keepStrings)
        +                             throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONArray using the JsonML transform. Each XML tag is represented as + a JSONArray in which the first element is the tag name. If the tag has + attributes, then the second element will be JSONObject containing the + name/value pairs. If the tag contains children, then strings and + JSONArrays will represent the child tags. + As opposed to toJSONArray this method does not attempt to convert + any text node or attribute value to any type + but just leaves it as a string. + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        keepStrings - If true, then values will not be coerced into boolean + or numeric values and will instead be left as strings
        +
        Returns:
        +
        A JSONArray containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONArray
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(XMLTokener x,
        +                                    boolean keepStrings)
        +                             throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONArray using the JsonML transform. Each XML tag is represented as + a JSONArray in which the first element is the tag name. If the tag has + attributes, then the second element will be JSONObject containing the + name/value pairs. If the tag contains children, then strings and + JSONArrays will represent the child content and tags. + As opposed to toJSONArray this method does not attempt to convert + any text node or attribute value to any type + but just leaves it as a string. + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        x - An XMLTokener.
        +
        keepStrings - If true, then values will not be coerced into boolean + or numeric values and will instead be left as strings
        +
        Returns:
        +
        A JSONArray containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONArray
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public static JSONArray toJSONArray(XMLTokener x)
        +                             throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONArray using the JsonML transform. Each XML tag is represented as + a JSONArray in which the first element is the tag name. If the tag has + attributes, then the second element will be JSONObject containing the + name/value pairs. If the tag contains children, then strings and + JSONArrays will represent the child content and tags. + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        x - An XMLTokener.
        +
        Returns:
        +
        A JSONArray containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONArray
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject using the JsonML transform. Each XML tag is represented as + a JSONObject with a "tagName" property. If the tag has attributes, then + the attributes will be in the JSONObject as properties. If the tag + contains children, the object will have a "childNodes" property which + will be an array of strings and JsonML JSONObjects. + + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        string - The XML source text.
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONObject
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string,
        +                                      boolean keepStrings)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject using the JsonML transform. Each XML tag is represented as + a JSONObject with a "tagName" property. If the tag has attributes, then + the attributes will be in the JSONObject as properties. If the tag + contains children, the object will have a "childNodes" property which + will be an array of strings and JsonML JSONObjects. + + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        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 strings
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONObject
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(XMLTokener x)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject using the JsonML transform. Each XML tag is represented as + a JSONObject with a "tagName" property. If the tag has attributes, then + the attributes will be in the JSONObject as properties. If the tag + contains children, the object will have a "childNodes" property which + will be an array of strings and JsonML JSONObjects. + + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        x - An XMLTokener of the XML source text.
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONObject
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(XMLTokener x,
        +                                      boolean keepStrings)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject using the JsonML transform. Each XML tag is represented as + a JSONObject with a "tagName" property. If the tag has attributes, then + the attributes will be in the JSONObject as properties. If the tag + contains children, the object will have a "childNodes" property which + will be an array of strings and JsonML JSONObjects. + + Comments, prologs, DTDs, and
         &lt;[ [ ]]>
        are ignored.
        +
        +
        Parameters:
        +
        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 strings
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a JSONObject
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONArray ja)
        +                       throws JSONException
        +
        Reverse the JSONML transformation, making an XML text from a JSONArray.
        +
        +
        Parameters:
        +
        ja - A JSONArray.
        +
        Returns:
        +
        An XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a string
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(JSONObject jo)
        +                       throws JSONException
        +
        Reverse the JSONML transformation, making an XML text from a JSONObject. + The JSONObject must contain a "tagName" property. If it has children, + then it must have a "childNodes" property containing an array of objects. + The other properties are attributes with string values.
        +
        +
        Parameters:
        +
        jo - A JSONObject.
        +
        Returns:
        +
        An XML string.
        +
        Throws:
        +
        JSONException - Thrown on error converting to a string
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONObject.html b/org/json/JSONObject.html new file mode 100644 index 0000000..12c58e3 --- /dev/null +++ b/org/json/JSONObject.html @@ -0,0 +1,2755 @@ + + + + + +JSONObject + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONObject

+
+
+ +
+
    +
  • +
    +
    +
    public class JSONObject
    +extends Object
    +
    A JSONObject is an unordered collection of name/value pairs. Its external + form is a string wrapped in curly braces with colons between the names and + values, and commas between the values and names. The internal form is an + object having 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: +

      +
    • An extra , (comma) may appear just + before the closing brace.
    • +
    • Strings may be quoted with ' (single + quote).
    • +
    • Strings do not need to be quoted at all if they do not begin with a + quote or single quote, and if they do not contain leading or trailing + spaces, and if they do not contain any of these characters: + { } [ ] / \ : , # and if they do not look like numbers and + if they are not the reserved words true, false, + or null.
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static ObjectNULL +
      It is sometimes more convenient and less ambiguous to have a + NULL object than to use Java's null value.
      +
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      ModifierConstructor 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.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      JSONObjectaccumulate(String key, + Object value) +
      Accumulate values under a key.
      +
      JSONObjectappend(String key, + Object value) +
      Append values to the array under a key.
      +
      static StringdoubleToString(double d) +
      Produce a string from a double.
      +
      protected Set<Map.Entry<String,Object>>entrySet() +
      Get a set of entries of the JSONObject.
      +
      Objectget(String key) +
      Get the value object associated with a key.
      +
      BigDecimalgetBigDecimal(String key) +
      Get the BigDecimal value associated with a key.
      +
      BigIntegergetBigInteger(String key) +
      Get the BigInteger value associated with a key.
      +
      booleangetBoolean(String key) +
      Get the boolean value associated with a key.
      +
      doublegetDouble(String key) +
      Get the double value associated with a key.
      +
      <E extends Enum<E>>
      E
      getEnum(Class<E> clazz, + String key) +
      Get the enum value associated with a key.
      +
      floatgetFloat(String key) +
      Get the float value associated with a key.
      +
      intgetInt(String key) +
      Get the int value associated with a key.
      +
      JSONArraygetJSONArray(String key) +
      Get the JSONArray value associated with a key.
      +
      JSONObjectgetJSONObject(String key) +
      Get the JSONObject value associated with a key.
      +
      longgetLong(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.
      +
      NumbergetNumber(String key) +
      Get the Number value associated with a key.
      +
      StringgetString(String key) +
      Get the string associated with a key.
      +
      booleanhas(String key) +
      Determine if the JSONObject contains a specific key.
      +
      JSONObjectincrement(String key) +
      Increment a property of a JSONObject.
      +
      protected static booleanisDecimalNotation(String val) +
      Tests if the value should be tried as a decimal.
      +
      booleanisEmpty() +
      Check if JSONObject is empty.
      +
      booleanisNull(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.
      +
      intlength() +
      Get the number of keys stored in the JSONObject.
      +
      JSONArraynames() +
      Produce a JSONArray containing the names of the elements of this + JSONObject.
      +
      static StringnumberToString(Number number) +
      Produce a string from a Number.
      +
      Objectopt(String key) +
      Get an optional value associated with a key.
      +
      BigDecimaloptBigDecimal(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.
      +
      BigIntegeroptBigInteger(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.
      +
      booleanoptBoolean(String key) +
      Get an optional boolean associated with a key.
      +
      booleanoptBoolean(String key, + boolean defaultValue) +
      Get an optional boolean associated with a key.
      +
      doubleoptDouble(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.
      +
      doubleoptDouble(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>>
      E
      optEnum(Class<E> clazz, + String key) +
      Get the enum value associated with a key.
      +
      <E extends Enum<E>>
      E
      optEnum(Class<E> clazz, + String key, + E defaultValue) +
      Get the enum value associated with a key.
      +
      floatoptFloat(String key) +
      Get the optional double value associated with an index.
      +
      floatoptFloat(String key, + float defaultValue) +
      Get the optional double value associated with an index.
      +
      intoptInt(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.
      +
      intoptInt(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.
      +
      JSONArrayoptJSONArray(String key) +
      Get an optional JSONArray associated with a key.
      +
      JSONObjectoptJSONObject(String key) +
      Get an optional JSONObject associated with a key.
      +
      longoptLong(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.
      +
      longoptLong(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.
      +
      NumberoptNumber(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.
      +
      NumberoptNumber(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.
      +
      ObjectoptQuery(JSONPointer jsonPointer) +
      Queries and returns a value from this object using jsonPointer, or + returns null if the query fails due to a missing key.
      +
      ObjectoptQuery(String jsonPointer) +
      Queries and returns a value from this object using jsonPointer, or + returns null if the query fails due to a missing key.
      +
      StringoptString(String key) +
      Get an optional string associated with a key.
      +
      StringoptString(String key, + String defaultValue) +
      Get an optional string associated with a key.
      +
      JSONObjectput(String key, + boolean value) +
      Put a key/boolean pair in the JSONObject.
      +
      JSONObjectput(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.
      +
      JSONObjectput(String key, + double value) +
      Put a key/double pair in the JSONObject.
      +
      JSONObjectput(String key, + float value) +
      Put a key/float pair in the JSONObject.
      +
      JSONObjectput(String key, + int value) +
      Put a key/int pair in the JSONObject.
      +
      JSONObjectput(String key, + long value) +
      Put a key/long pair in the JSONObject.
      +
      JSONObjectput(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.
      +
      JSONObjectput(String key, + Object value) +
      Put a key/value pair in the JSONObject.
      +
      JSONObjectputOnce(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.
      +
      JSONObjectputOpt(String key, + Object value) +
      Put a key/value pair in the JSONObject, but only if the key and the value + are both non-null.
      +
      Objectquery(JSONPointer jsonPointer) +
      Uses a user initialized JSONPointer and tries to + match it to an item within this JSONObject.
      +
      Objectquery(String jsonPointer) +
      Creates a JSONPointer using an initialization string and tries to + match it to an item within this JSONObject.
      +
      static Stringquote(String string) +
      Produce a string in double quotes with backslash sequences in all the + right places.
      +
      static Writerquote(String string, + Writer w) 
      Objectremove(String key) +
      Remove a name and its value, if present.
      +
      booleansimilar(Object other) +
      Determine if two JSONObjects are similar.
      +
      protected static NumberstringToNumber(String val) +
      Converts a string to a number using the narrowest possible type.
      +
      static ObjectstringToValue(String string) +
      Try to convert a string into a number, boolean, or null.
      +
      static voidtestValidity(Object o) +
      Throw an exception if the object is a NaN or infinite number.
      +
      JSONArraytoJSONArray(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.
      +
      StringtoString() +
      Make a JSON text of this JSONObject.
      +
      StringtoString(int indentFactor) +
      Make a pretty-printed JSON text of this JSONObject.
      +
      static StringvalueToString(Object value) +
      Make a JSON text of an Object value.
      +
      static Objectwrap(Object object) +
      Wrap an object, if necessary.
      +
      Writerwrite(Writer writer) +
      Write the contents of the JSONObject as JSON text to a writer.
      +
      Writerwrite(Writer writer, + int indentFactor, + int indent) +
      Write the contents of the JSONObject as JSON text to a writer.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        NULL

        +
        public static final Object NULL
        +
        It is sometimes more convenient and less ambiguous to have a + NULL object than to use Java's null value. + JSONObject.NULL.equals(null) returns true. + JSONObject.NULL.toString() returns "null".
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject()
        +
        Construct an empty JSONObject.
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(JSONObject jo,
        +                  String... names)
        +
        Construct a JSONObject from a subset of another JSONObject. An array of + strings is used to identify the keys that should be copied. Missing keys + are ignored.
        +
        +
        Parameters:
        +
        jo - A JSONObject.
        +
        names - An array of strings.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(JSONTokener x)
        +           throws JSONException
        +
        Construct a JSONObject from a JSONTokener.
        +
        +
        Parameters:
        +
        x - A JSONTokener object containing the source string.
        +
        Throws:
        +
        JSONException - If there is a syntax error in the source string or a + duplicated key.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(Map<?,?> m)
        +
        Construct a JSONObject from a Map.
        +
        +
        Parameters:
        +
        m - A map object that can be used to initialize the contents of + the JSONObject.
        +
        Throws:
        +
        JSONException - If a value in the map is non-finite number.
        +
        NullPointerException - If a key in the map is null
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(Object bean)
        +
        Construct a JSONObject from an Object using bean getters. It reflects on + all of the public methods of the object. For each of the methods with no + parameters and a name starting with "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; }
        + 
        +

        +
        +
        Parameters:
        +
        bean - An object that has getter methods that should be used to make + a JSONObject.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(Object object,
        +                  String... names)
        +
        Construct a JSONObject from an Object, using reflection to find the + public members. The resulting JSONObject's keys will be the strings from + the names array, and the values will be the field values associated with + those keys in the object. If a key is not found or not visible, then it + will not be copied into the new JSONObject.
        +
        +
        Parameters:
        +
        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.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(String source)
        +           throws JSONException
        +
        Construct a JSONObject from a source JSON text string. This is the most + commonly used JSONObject constructor.
        +
        +
        Parameters:
        +
        source - A string beginning with { (left + brace) and ending with } +  (right brace).
        +
        Throws:
        +
        JSONException - If there is a syntax error in the source string or a + duplicated key.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        public JSONObject(String baseName,
        +                  Locale locale)
        +           throws JSONException
        +
        Construct a JSONObject from a ResourceBundle.
        +
        +
        Parameters:
        +
        baseName - The ResourceBundle base name.
        +
        locale - The Locale to load the ResourceBundle for.
        +
        Throws:
        +
        JSONException - If any JSONExceptions are detected.
        +
        +
      • +
      + + + +
        +
      • +

        JSONObject

        +
        protected JSONObject(int initialCapacity)
        +
        Constructor to specify an initial capacity of the internal map. Useful for library + internal calls where we know, or at least can best guess, how big this JSONObject + will be.
        +
        +
        Parameters:
        +
        initialCapacity - initial capacity of the internal map.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accumulate

        +
        public JSONObject accumulate(String key,
        +                             Object value)
        +                      throws JSONException
        +
        Accumulate values under a key. It is similar to the put method except + that if there is already an object stored under the key then a JSONArray + is stored under the key to hold all of the accumulated values. If there + is already a JSONArray, then the new value is appended to it. In + contrast, the put method replaces the previous value. + + If only one value is accumulated that is not a JSONArray, then the result + will be the same as using put. But if multiple values are accumulated, + then the result will be like append.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - An object to be accumulated under the key.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        append

        +
        public JSONObject append(String key,
        +                         Object value)
        +                  throws JSONException
        +
        Append values to the array under a key. If the key does not exist in the + JSONObject, then the key is put in the JSONObject with its value being a + JSONArray containing the value parameter. If the key was already + associated with a JSONArray, then the value parameter is appended to it.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - An object to be accumulated under the key.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        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.
        +
        +
      • +
      + + + +
        +
      • +

        doubleToString

        +
        public static String doubleToString(double d)
        +
        Produce a string from a double. The string "null" will be returned if the + number is not finite.
        +
        +
        Parameters:
        +
        d - A double.
        +
        Returns:
        +
        A String.
        +
        +
      • +
      + + + +
        +
      • +

        get

        +
        public Object get(String key)
        +           throws JSONException
        +
        Get the value object associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The object associated with the key.
        +
        Throws:
        +
        JSONException - if the key is not found.
        +
        +
      • +
      + + + +
        +
      • +

        getEnum

        +
        public <E extends Enum<E>> E getEnum(Class<E> clazz,
        +                                     String key)
        +                              throws JSONException
        +
        Get the enum value associated with a key.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        clazz - The type of enum to retrieve.
        +
        key - A key string.
        +
        Returns:
        +
        The enum value associated with the key
        +
        Throws:
        +
        JSONException - if the key is not found or if the value cannot be converted + to an enum.
        +
        +
      • +
      + + + +
        +
      • +

        getBoolean

        +
        public boolean getBoolean(String key)
        +                   throws JSONException
        +
        Get the boolean value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The truth.
        +
        Throws:
        +
        JSONException - if the value is not a Boolean or the String "true" or + "false".
        +
        +
      • +
      + + + +
        +
      • +

        getBigInteger

        +
        public BigInteger getBigInteger(String key)
        +                         throws JSONException
        +
        Get the BigInteger value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value cannot + be converted to BigInteger.
        +
        +
      • +
      + + + +
        +
      • +

        getBigDecimal

        +
        public BigDecimal getBigDecimal(String key)
        +                         throws JSONException
        +
        Get the BigDecimal value associated with a key. If the value is float or + double, the the BigDecimal.BigDecimal(double) constructor will + be used. See notes on the constructor for conversion issues that may + arise.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value + cannot be converted to BigDecimal.
        +
        +
      • +
      + + + +
        +
      • +

        getDouble

        +
        public double getDouble(String key)
        +                 throws JSONException
        +
        Get the double value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a Number + object and cannot be converted to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getFloat

        +
        public float getFloat(String key)
        +               throws JSONException
        +
        Get the float value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a Number + object and cannot be converted to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getNumber

        +
        public Number getNumber(String key)
        +                 throws JSONException
        +
        Get the Number value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The numeric value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a Number + object and cannot be converted to a number.
        +
        +
      • +
      + + + +
        +
      • +

        getInt

        +
        public int getInt(String key)
        +           throws JSONException
        +
        Get the int value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The integer value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value cannot be converted + to an integer.
        +
        +
      • +
      + + + +
        +
      • +

        getJSONArray

        +
        public JSONArray getJSONArray(String key)
        +                       throws JSONException
        +
        Get the JSONArray value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A JSONArray which is the value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a JSONArray.
        +
        +
      • +
      + + + +
        +
      • +

        getJSONObject

        +
        public JSONObject getJSONObject(String key)
        +                         throws JSONException
        +
        Get the JSONObject value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A JSONObject which is the value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value is not a JSONObject.
        +
        +
      • +
      + + + +
        +
      • +

        getLong

        +
        public long getLong(String key)
        +             throws JSONException
        +
        Get the long value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The long value.
        +
        Throws:
        +
        JSONException - if the key is not found or if the value cannot be converted + to a long.
        +
        +
      • +
      + + + +
        +
      • +

        getNames

        +
        public static String[] getNames(JSONObject jo)
        +
        Get an array of field names from a JSONObject.
        +
        +
        Parameters:
        +
        jo - JSON object
        +
        Returns:
        +
        An array of field names, or null if there are no names.
        +
        +
      • +
      + + + +
        +
      • +

        getNames

        +
        public static String[] getNames(Object object)
        +
        Get an array of public field names from an Object.
        +
        +
        Parameters:
        +
        object - object to read
        +
        Returns:
        +
        An array of field names, or null if there are no names.
        +
        +
      • +
      + + + +
        +
      • +

        getString

        +
        public String getString(String key)
        +                 throws JSONException
        +
        Get the string associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A string which is the value.
        +
        Throws:
        +
        JSONException - if there is no string value for the key.
        +
        +
      • +
      + + + +
        +
      • +

        has

        +
        public boolean has(String key)
        +
        Determine if the JSONObject contains a specific key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        true if the key exists in the JSONObject.
        +
        +
      • +
      + + + +
        +
      • +

        increment

        +
        public JSONObject increment(String key)
        +                     throws JSONException
        +
        Increment a property of a JSONObject. If there is no such property, + create one with a value of 1 (Integer). If there is such a property, and if it is + an Integer, Long, Double, Float, BigInteger, or BigDecimal then add one to it. + No overflow bounds checking is performed, so callers should initialize the key + prior to this call with an appropriate type that can handle the maximum expected + value.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If there is already a property with this name that is not an + Integer, Long, Double, or Float.
        +
        +
      • +
      + + + +
        +
      • +

        isNull

        +
        public boolean isNull(String key)
        +
        Determine if the value associated with the key is null or if there is no + value.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        true if there is no value associated with the key or if the value + is the JSONObject.NULL object.
        +
        +
      • +
      + + + +
        +
      • +

        keys

        +
        public Iterator<String> keys()
        +
        Get an enumeration of the keys of the JSONObject. Modifying this key Set will also + modify the JSONObject. Use with caution.
        +
        +
        Returns:
        +
        An iterator of the keys.
        +
        See Also:
        +
        Set.iterator()
        +
        +
      • +
      + + + +
        +
      • +

        keySet

        +
        public Set<String> keySet()
        +
        Get a set of keys of the JSONObject. Modifying this key Set will also modify the + JSONObject. Use with caution.
        +
        +
        Returns:
        +
        A keySet.
        +
        See Also:
        +
        Map.keySet()
        +
        +
      • +
      + + + +
        +
      • +

        entrySet

        +
        protected Set<Map.Entry<String,Object>> entrySet()
        +
        Get a set of entries of the JSONObject. These are raw values and may not + match what is returned by the JSONObject get* and opt* functions. Modifying + the returned EntrySet or the Entry objects contained therein will modify the + backing JSONObject. This does not return a clone or a read-only view. + + Use with caution.
        +
        +
        Returns:
        +
        An Entry Set
        +
        See Also:
        +
        Map.entrySet()
        +
        +
      • +
      + + + +
        +
      • +

        length

        +
        public int length()
        +
        Get the number of keys stored in the JSONObject.
        +
        +
        Returns:
        +
        The number of keys in the JSONObject.
        +
        +
      • +
      + + + +
        +
      • +

        isEmpty

        +
        public boolean isEmpty()
        +
        Check if JSONObject is empty.
        +
        +
        Returns:
        +
        true if JSONObject is empty, otherwise false.
        +
        +
      • +
      + + + +
        +
      • +

        names

        +
        public JSONArray names()
        +
        Produce a JSONArray containing the names of the elements of this + JSONObject.
        +
        +
        Returns:
        +
        A JSONArray containing the key strings, or null if the JSONObject + is empty.
        +
        +
      • +
      + + + +
        +
      • +

        numberToString

        +
        public static String numberToString(Number number)
        +                             throws JSONException
        +
        Produce a string from a Number.
        +
        +
        Parameters:
        +
        number - A Number
        +
        Returns:
        +
        A String.
        +
        Throws:
        +
        JSONException - If n is a non-finite number.
        +
        +
      • +
      + + + +
        +
      • +

        opt

        +
        public Object opt(String key)
        +
        Get an optional value associated with a key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        An object which is the value, or null if there is no value.
        +
        +
      • +
      + + + +
        +
      • +

        optEnum

        +
        public <E extends Enum<E>> E optEnum(Class<E> clazz,
        +                                     String key)
        +
        Get the enum value associated with a key.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        clazz - The type of enum to retrieve.
        +
        key - A key string.
        +
        Returns:
        +
        The enum value associated with the key or null if not found
        +
        +
      • +
      + + + + + +
        +
      • +

        optEnum

        +
        public <E extends Enum<E>> E optEnum(Class<E> clazz,
        +                                     String key,
        +                                     E defaultValue)
        +
        Get the enum value associated with a key.
        +
        +
        Type Parameters:
        +
        E - Enum Type
        +
        Parameters:
        +
        clazz - The type of enum to retrieve.
        +
        key - A key string.
        +
        defaultValue - The default in case the value is not found
        +
        Returns:
        +
        The enum value associated with the key or defaultValue + if the value is not found or cannot be assigned to clazz
        +
        +
      • +
      + + + +
        +
      • +

        optBoolean

        +
        public boolean optBoolean(String key)
        +
        Get an optional boolean associated with a key. It returns false if there + is no such key, or if the value is not Boolean.TRUE or the String "true".
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The truth.
        +
        +
      • +
      + + + +
        +
      • +

        optBoolean

        +
        public boolean optBoolean(String key,
        +                          boolean defaultValue)
        +
        Get an optional boolean associated with a key. It returns the + defaultValue if there is no such key, or if it is not a Boolean or the + String "true" or "false" (case insensitive).
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        The truth.
        +
        +
      • +
      + + + +
        +
      • +

        optBigDecimal

        +
        public 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. If the value is a + string, an attempt will be made to evaluate it as a number. If the value + is float or double, then the BigDecimal.BigDecimal(double) + constructor will be used. See notes on the constructor for conversion + issues that may arise.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optBigInteger

        +
        public 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. If the value is a + string, an attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optDouble

        +
        public 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. If the value is a string, an attempt + will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A string which is the key.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optDouble

        +
        public 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. If the value is a + string, an attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optFloat

        +
        public float optFloat(String key)
        +
        Get the optional double value associated with an index. NaN is returned + if there is no value for the index, or if the value is not a number and + cannot be converted to a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optFloat

        +
        public float optFloat(String key,
        +                      float defaultValue)
        +
        Get the optional double value associated with an index. The defaultValue + is returned if there is no value for the index, or if the value is not a + number and cannot be converted to a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default value.
        +
        Returns:
        +
        The value.
        +
        +
      • +
      + + + +
        +
      • +

        optInt

        +
        public 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. If the value is a string, an + attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optInt

        +
        public 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. If the value is a string, + an attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optJSONArray

        +
        public JSONArray optJSONArray(String key)
        +
        Get an optional JSONArray associated with a key. It returns null if there + is no such key, or if its value is not a JSONArray.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A JSONArray which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optJSONObject

        +
        public JSONObject optJSONObject(String key)
        +
        Get an optional JSONObject associated with a key. It returns null if + there is no such key, or if its value is not a JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A JSONObject which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optLong

        +
        public 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. If the value is a string, an + attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optLong

        +
        public 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. If the value is a string, + an attempt will be made to evaluate it as a number.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optNumber

        +
        public 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. 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.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optNumber

        +
        public 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. 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.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        An object which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optString

        +
        public String optString(String key)
        +
        Get an optional string associated with a key. It returns an empty string + if there is no such key. If the value is not a string and is not null, + then it is converted to a string.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        Returns:
        +
        A string which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        optString

        +
        public String optString(String key,
        +                        String defaultValue)
        +
        Get an optional string associated with a key. It returns the defaultValue + if there is no such key.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        defaultValue - The default.
        +
        Returns:
        +
        A string which is the value.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      boolean value)
        +               throws JSONException
        +
        Put a key/boolean pair in the JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A boolean which is the value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      Collection<?> value)
        +               throws JSONException
        +
        Put a key/value pair in the JSONObject, where the value will be a + JSONArray which is produced from a Collection.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A Collection value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      double value)
        +               throws JSONException
        +
        Put a key/double pair in the JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A double which is the value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      float value)
        +               throws JSONException
        +
        Put a key/float pair in the JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A float which is the value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      int value)
        +               throws JSONException
        +
        Put a key/int pair in the JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - An int which is the value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      long value)
        +               throws JSONException
        +
        Put a key/long pair in the JSONObject.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A long which is the value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      Map<?,?> value)
        +               throws JSONException
        +
        Put a key/value pair in the JSONObject, where the value will be a + JSONObject which is produced from a Map.
        +
        +
        Parameters:
        +
        key - A key string.
        +
        value - A Map value.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        put

        +
        public JSONObject put(String key,
        +                      Object value)
        +               throws JSONException
        +
        Put a key/value pair in the JSONObject. If the value is null, then the + key will be removed from the JSONObject if it is present.
        +
        +
        Parameters:
        +
        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.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is non-finite number.
        +
        NullPointerException - If the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        putOnce

        +
        public JSONObject putOnce(String key,
        +                          Object value)
        +                   throws JSONException
        +
        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.
        +
        +
        Parameters:
        +
        key - key to insert into
        +
        value - value to insert
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - if the key is a duplicate
        +
        +
      • +
      + + + +
        +
      • +

        putOpt

        +
        public JSONObject putOpt(String key,
        +                         Object value)
        +                  throws JSONException
        +
        Put a key/value pair in the JSONObject, but only if the key and the value + are both non-null.
        +
        +
        Parameters:
        +
        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.
        +
        Returns:
        +
        this.
        +
        Throws:
        +
        JSONException - If the value is a non-finite number.
        +
        +
      • +
      + + + +
        +
      • +

        query

        +
        public Object query(String jsonPointer)
        +
        Creates a JSONPointer using an initialization string and tries to + match it to an item within this JSONObject. For example, given a + JSONObject initialized with this document: +
        + {
        +     "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.
        +
        +
        Parameters:
        +
        jsonPointer - string that can be used to create a JSONPointer
        +
        Returns:
        +
        the item matched by the JSONPointer, otherwise null
        +
        +
      • +
      + + + +
        +
      • +

        query

        +
        public Object query(JSONPointer jsonPointer)
        +
        Uses a user initialized JSONPointer and tries to + match it to an item within this JSONObject. For example, given a + JSONObject initialized with this document: +
        + {
        +     "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.
        +
        +
        Parameters:
        +
        jsonPointer - string that can be used to create a JSONPointer
        +
        Returns:
        +
        the item matched by the JSONPointer, otherwise null
        +
        +
      • +
      + + + +
        +
      • +

        optQuery

        +
        public 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.
        +
        +
        Parameters:
        +
        jsonPointer - the string representation of the JSON pointer
        +
        Returns:
        +
        the queried value or null
        +
        Throws:
        +
        IllegalArgumentException - if jsonPointer has invalid syntax
        +
        +
      • +
      + + + +
        +
      • +

        optQuery

        +
        public 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.
        +
        +
        Parameters:
        +
        jsonPointer - The JSON pointer
        +
        Returns:
        +
        the queried value or null
        +
        Throws:
        +
        IllegalArgumentException - if jsonPointer has invalid syntax
        +
        +
      • +
      + + + +
        +
      • +

        quote

        +
        public static String quote(String string)
        +
        Produce a string in double quotes with backslash sequences in all the + right places. A backslash will be inserted within </, producing + <\/, allowing JSON text to be delivered in HTML. In JSON text, a + string cannot contain a control character or an unescaped quote or + backslash.
        +
        +
        Parameters:
        +
        string - A String
        +
        Returns:
        +
        A String correctly formatted for insertion in a JSON text.
        +
        +
      • +
      + + + + + + + +
        +
      • +

        remove

        +
        public Object remove(String key)
        +
        Remove a name and its value, if present.
        +
        +
        Parameters:
        +
        key - The name to be removed.
        +
        Returns:
        +
        The value that was associated with the name, or null if there was + no value.
        +
        +
      • +
      + + + +
        +
      • +

        similar

        +
        public boolean similar(Object other)
        +
        Determine if two JSONObjects are similar. + They must contain the same set of names which must be associated with + similar values.
        +
        +
        Parameters:
        +
        other - The other JSONObject
        +
        Returns:
        +
        true if they are equal
        +
        +
      • +
      + + + +
        +
      • +

        isDecimalNotation

        +
        protected static boolean isDecimalNotation(String val)
        +
        Tests if the value should be tried as a decimal. It makes no test if there are actual digits.
        +
        +
        Parameters:
        +
        val - value to test
        +
        Returns:
        +
        true if the string is "-0" or if it contains '.', 'e', or 'E', false otherwise.
        +
        +
      • +
      + + + +
        +
      • +

        stringToNumber

        +
        protected static Number stringToNumber(String val)
        +                                throws NumberFormatException
        +
        Converts a string to a number using the narrowest possible type. Possible + returns for this function are BigDecimal, Double, BigInteger, Long, and Integer. + When a Double is returned, it should always be a valid Double and not NaN or +-infinity.
        +
        +
        Parameters:
        +
        val - value to convert
        +
        Returns:
        +
        Number representation of the value.
        +
        Throws:
        +
        NumberFormatException - thrown if the value is not a valid number. A public + caller should catch this and wrap it in a JSONException if applicable.
        +
        +
      • +
      + + + +
        +
      • +

        stringToValue

        +
        public static Object stringToValue(String string)
        +
        Try to convert a string into a number, boolean, or null. If the string + can't be converted, return the string.
        +
        +
        Parameters:
        +
        string - A String. can not be null.
        +
        Returns:
        +
        A simple JSON value.
        +
        Throws:
        +
        NullPointerException - Thrown if the string is null.
        +
        +
      • +
      + + + +
        +
      • +

        testValidity

        +
        public static void testValidity(Object o)
        +                         throws JSONException
        +
        Throw an exception if the object is a NaN or infinite number.
        +
        +
        Parameters:
        +
        o - The object to test.
        +
        Throws:
        +
        JSONException - If o is a non-finite number.
        +
        +
      • +
      + + + +
        +
      • +

        toJSONArray

        +
        public JSONArray toJSONArray(JSONArray names)
        +                      throws JSONException
        +
        Produce a JSONArray containing the values of the members of this + JSONObject.
        +
        +
        Parameters:
        +
        names - A JSONArray containing a list of key strings. This determines + the sequence of the values in the result.
        +
        Returns:
        +
        A JSONArray of values.
        +
        Throws:
        +
        JSONException - If any of the values are non-finite numbers.
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Make a JSON text of this JSONObject. For compactness, no whitespace is + added. If this would not result in a syntactically correct JSON text, + then null will be returned instead. +

        + Warning: This method assumes that the data structure is acyclical. +

        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        +
        a printable, displayable, portable, transmittable representation + of the object, beginning with { (left + brace) and ending with } (right + brace).
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString(int indentFactor)
        +                throws JSONException
        +
        Make a pretty-printed JSON text of this JSONObject. + +

        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. +

        +
        +
        Parameters:
        +
        indentFactor - The number of spaces to add to each level of indentation.
        +
        Returns:
        +
        a printable, displayable, portable, transmittable representation + of the object, beginning with { (left + brace) and ending with } (right + brace).
        +
        Throws:
        +
        JSONException - If the object contains an invalid number.
        +
        +
      • +
      + + + +
        +
      • +

        valueToString

        +
        public static String valueToString(Object value)
        +                            throws JSONException
        +
        Make a JSON text of an Object value. If the object has an + value.toJSONString() method, then that method will be used to produce the + JSON text. The method is required to produce a strictly conforming text. + If the object does not contain a toJSONString method (which is the most + common case), then a text will be produced by other means. If the value + is an array or Collection, then a JSONArray will be made from it and its + toJSONString method will be called. If the value is a MAP, then a + JSONObject will be made from it and its toJSONString method will be + called. Otherwise, the value's toString method will be called, and the + result will be quoted. + +

        + Warning: This method assumes that the data structure is acyclical.

        +
        +
        Parameters:
        +
        value - The value to be serialized.
        +
        Returns:
        +
        a printable, displayable, transmittable representation of the + object, beginning with { (left + brace) and ending with } (right + brace).
        +
        Throws:
        +
        JSONException - If the value is or contains an invalid number.
        +
        +
      • +
      + + + +
        +
      • +

        wrap

        +
        public static Object wrap(Object object)
        +
        Wrap an object, if necessary. If the object is 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.
        +
        +
        Parameters:
        +
        object - The object to wrap
        +
        Returns:
        +
        The wrapped value
        +
        +
      • +
      + + + +
        +
      • +

        write

        +
        public Writer write(Writer writer)
        +             throws JSONException
        +
        Write the contents of the JSONObject as JSON text to a writer. For + compactness, no whitespace is added. +

        + Warning: This method assumes that the data structure is acyclical. +

        +
        +
        Parameters:
        +
        writer - the writer object
        +
        Returns:
        +
        The writer.
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      + + + +
        +
      • +

        write

        +
        public Writer write(Writer writer,
        +                    int indentFactor,
        +                    int indent)
        +             throws JSONException
        +
        Write the contents of the JSONObject as JSON text to a writer. + +

        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. +

        +
        +
        Parameters:
        +
        writer - Writes the serialized JSON
        +
        indentFactor - The number of spaces to add to each level of indentation.
        +
        indent - The indentation of the top level.
        +
        Returns:
        +
        The writer.
        +
        Throws:
        +
        JSONException - if a called function has an error or a write error + occurs
        +
        +
      • +
      + + + +
        +
      • +

        toMap

        +
        public Map<String,Object> toMap()
        +
        Returns a java.util.Map containing all of the entries in this object. + If an entry in the object is a JSONArray or JSONObject it will also + be converted. +

        + Warning: This method assumes that the data structure is acyclical.

        +
        +
        Returns:
        +
        a java.util.Map containing the entries of this object
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONPointer.Builder.html b/org/json/JSONPointer.Builder.html new file mode 100644 index 0000000..7d9187f --- /dev/null +++ b/org/json/JSONPointer.Builder.html @@ -0,0 +1,334 @@ + + + + + +JSONPointer.Builder + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONPointer.Builder

+
+
+ +
+
    +
  • +
    +
    Enclosing class:
    +
    JSONPointer
    +
    +
    +
    +
    public static class JSONPointer.Builder
    +extends Object
    +
    This class allows the user to build a JSONPointer in steps, using + exactly one segment in each step.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Builder

        +
        public Builder()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        build

        +
        public JSONPointer build()
        +
        Creates a JSONPointer instance using the tokens previously set using the + append(String) method calls.
        +
        +
        Returns:
        +
        a JSONPointer object
        +
        +
      • +
      + + + +
        +
      • +

        append

        +
        public JSONPointer.Builder append(String token)
        +
        Adds an arbitrary token to the list of reference tokens. It can be any non-null value. + + Unlike in the case of JSON string or URI fragment representation of JSON pointers, the + argument of this method MUST NOT be escaped. If you want to query the property called + "a~b" then you should simply pass the "a~b" string as-is, there is no + need to escape it as "a~0b".
        +
        +
        Parameters:
        +
        token - the new token to be appended to the list
        +
        Returns:
        +
        this
        +
        Throws:
        +
        NullPointerException - if token is null
        +
        +
      • +
      + + + +
        +
      • +

        append

        +
        public JSONPointer.Builder append(int arrayIndex)
        +
        Adds an integer to the reference token list. Although not necessarily, mostly this token will + denote an array index.
        +
        +
        Parameters:
        +
        arrayIndex - the array index to be added to the token list
        +
        Returns:
        +
        this
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONPointer.html b/org/json/JSONPointer.html new file mode 100644 index 0000000..81751c8 --- /dev/null +++ b/org/json/JSONPointer.html @@ -0,0 +1,414 @@ + + + + + +JSONPointer + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONPointer

+
+
+ +
+
    +
  • +
    +
    +
    public class JSONPointer
    +extends Object
    +
    A JSON Pointer is a simple query language defined for JSON documents by + RFC 6901. + + In a nutshell, JSONPointer allows the user to navigate into a JSON document + using strings, and retrieve targeted objects, like a simple form of XPATH. + Path segments are separated by the '/' char, which signifies the root of + the document when it appears as the first char of the string. Array + elements are navigated using ordinals, counting from 0. JSONPointer strings + may be extended to any arbitrary number of segments. If the navigation + is successful, the matched item is returned. A matched item may be a + JSONObject, a JSONArray, or a JSON value. If the JSONPointer string building + fails, an appropriate exception is thrown. If the navigation fails to find + a match, a JSONPointerException is thrown.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONPointer

        +
        public JSONPointer(String pointer)
        +
        Pre-parses and initializes a new 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.
        +
        +
        Parameters:
        +
        pointer - the JSON String or URI Fragment representation of the JSON pointer.
        +
        Throws:
        +
        IllegalArgumentException - if pointer is not a valid JSON pointer
        +
        +
      • +
      + + + +
        +
      • +

        JSONPointer

        +
        public JSONPointer(List<String> refTokens)
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        builder

        +
        public static JSONPointer.Builder builder()
        +
        Static factory method for JSONPointer.Builder. Example usage: + +
        
        + JSONPointer pointer = JSONPointer.builder()
        +       .append("obj")
        +       .append("other~key").append("another/key")
        +       .append("\"")
        +       .append(0)
        +       .build();
        + 
        +
        +
        Returns:
        +
        a builder instance which can be used to construct a JSONPointer instance by chained + JSONPointer.Builder.append(String) calls.
        +
        +
      • +
      + + + +
        +
      • +

        queryFrom

        +
        public Object queryFrom(Object document)
        +                 throws JSONPointerException
        +
        Evaluates this JSON Pointer on the given 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.
        +
        +
        Parameters:
        +
        document - the JSON document which should be the subject of querying.
        +
        Returns:
        +
        the result of the evaluation
        +
        Throws:
        +
        JSONPointerException - if an error occurs during evaluation
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Returns a string representing the JSONPointer path value using string + representation
        +
        +
        Overrides:
        +
        toString in class Object
        +
        +
      • +
      + + + +
        +
      • +

        toURIFragment

        +
        public String toURIFragment()
        +
        Returns a string representing the JSONPointer path value using URI + fragment identifier representation
        +
        +
        Returns:
        +
        a uri fragment string
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONPointerException.html b/org/json/JSONPointerException.html new file mode 100644 index 0000000..0e91c8f --- /dev/null +++ b/org/json/JSONPointerException.html @@ -0,0 +1,284 @@ + + + + + +JSONPointerException + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONPointerException

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONPointerException

        +
        public JSONPointerException(String message)
        +
      • +
      + + + +
        +
      • +

        JSONPointerException

        +
        public JSONPointerException(String message,
        +                            Throwable cause)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONPropertyIgnore.html b/org/json/JSONPropertyIgnore.html new file mode 100644 index 0000000..2d49133 --- /dev/null +++ b/org/json/JSONPropertyIgnore.html @@ -0,0 +1,162 @@ + + + + + +JSONPropertyIgnore + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Annotation Type JSONPropertyIgnore

+
+
+
+ +
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONPropertyName.html b/org/json/JSONPropertyName.html new file mode 100644 index 0000000..a50aeab --- /dev/null +++ b/org/json/JSONPropertyName.html @@ -0,0 +1,214 @@ + + + + + +JSONPropertyName + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Annotation Type JSONPropertyName

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Stringvalue 
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract String value
        +
        +
        Returns:
        +
        The name of the property as to be used in the JSON Object.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONString.html b/org/json/JSONString.html new file mode 100644 index 0000000..c13ce5b --- /dev/null +++ b/org/json/JSONString.html @@ -0,0 +1,232 @@ + + + + + +JSONString + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Interface JSONString

+
+
+
+
    +
  • +
    +
    +
    public interface 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). The + toJSONString method will be used instead of the default behavior + of using the Object's toString() method and quoting the result.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJSONString

        +
        String toJSONString()
        +
        The toJSONString method allows a class to produce its own JSON + serialization.
        +
        +
        Returns:
        +
        A strictly syntactically correct JSON text.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONStringer.html b/org/json/JSONStringer.html new file mode 100644 index 0000000..e4ce09a --- /dev/null +++ b/org/json/JSONStringer.html @@ -0,0 +1,336 @@ + + + + + +JSONStringer + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONStringer

+
+
+ +
+
    +
  • +
    +
    +
    public class JSONStringer
    +extends JSONWriter
    +
    JSONStringer provides a quick and convenient way of producing JSON text. + The texts produced strictly conform to JSON syntax rules. No whitespace is + added, so the results are ready for transmission or storage. Each instance of + JSONStringer can produce one JSON text. +

    + 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.

    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONStringer

        +
        public JSONStringer()
        +
        Make a fresh JSONStringer. It can be used to build one JSON text.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Return the JSON text. This method is used to obtain the product of the + JSONStringer instance. It will return 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).
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        +
        The JSON text.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONTokener.html b/org/json/JSONTokener.html new file mode 100644 index 0000000..03f9dfd --- /dev/null +++ b/org/json/JSONTokener.html @@ -0,0 +1,705 @@ + + + + + +JSONTokener + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONTokener

+
+
+ +
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    HTTPTokener, XMLTokener
    +
    +
    +
    +
    public class JSONTokener
    +extends Object
    +
    A JSONTokener takes a source string and extracts characters and tokens from + it. It is used by the JSONObject and JSONArray constructors to parse + JSON source strings.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      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.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      voidback() +
      Back up one character.
      +
      static intdehexchar(char c) +
      Get the hex value of a character (base16).
      +
      booleanend() +
      Checks if the end of the input has been reached.
      +
      booleanmore() +
      Determine if the source string still contains characters that next() + can consume.
      +
      charnext() +
      Get the next character in the source string.
      +
      charnext(char c) +
      Consume the next character, and check that it matches a specified + character.
      +
      Stringnext(int n) +
      Get the next n characters.
      +
      charnextClean() +
      Get the next char in the string, skipping whitespace.
      +
      StringnextString(char quote) +
      Return the characters up to the next close quote character.
      +
      StringnextTo(char delimiter) +
      Get the text up but not including the specified character or the + end of line, whichever comes first.
      +
      StringnextTo(String delimiters) +
      Get the text up but not including one of the specified delimiter + characters or the end of line, whichever comes first.
      +
      ObjectnextValue() +
      Get the next value.
      +
      charskipTo(char to) +
      Skip characters until the next character is the requested character.
      +
      JSONExceptionsyntaxError(String message) +
      Make a JSONException to signal a syntax error.
      +
      JSONExceptionsyntaxError(String message, + Throwable causedBy) +
      Make a JSONException to signal a syntax error.
      +
      StringtoString() +
      Make a printable string of this JSONTokener.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONTokener

        +
        public JSONTokener(Reader reader)
        +
        Construct a JSONTokener from a Reader. The caller must close the Reader.
        +
        +
        Parameters:
        +
        reader - A reader.
        +
        +
      • +
      + + + +
        +
      • +

        JSONTokener

        +
        public JSONTokener(InputStream inputStream)
        +
        Construct a JSONTokener from an InputStream. The caller must close the input stream.
        +
        +
        Parameters:
        +
        inputStream - The source.
        +
        +
      • +
      + + + +
        +
      • +

        JSONTokener

        +
        public JSONTokener(String s)
        +
        Construct a JSONTokener from a string.
        +
        +
        Parameters:
        +
        s - A source string.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        back

        +
        public void back()
        +          throws JSONException
        +
        Back up one character. This provides a sort of lookahead capability, + so that you can test for a digit or letter before attempting to parse + the next number or identifier.
        +
        +
        Throws:
        +
        JSONException - Thrown if trying to step back more than 1 step + or if already at the start of the string
        +
        +
      • +
      + + + +
        +
      • +

        dehexchar

        +
        public static int dehexchar(char c)
        +
        Get the hex value of a character (base16).
        +
        +
        Parameters:
        +
        c - A character between '0' and '9' or between 'A' and 'F' or + between 'a' and 'f'.
        +
        Returns:
        +
        An int between 0 and 15, or -1 if c was not a hex digit.
        +
        +
      • +
      + + + +
        +
      • +

        end

        +
        public boolean end()
        +
        Checks if the end of the input has been reached.
        +
        +
        Returns:
        +
        true if at the end of the file and we didn't step back
        +
        +
      • +
      + + + +
        +
      • +

        more

        +
        public boolean more()
        +             throws JSONException
        +
        Determine if the source string still contains characters that next() + can consume.
        +
        +
        Returns:
        +
        true if not yet at the end of the source.
        +
        Throws:
        +
        JSONException - thrown if there is an error stepping forward + or backward while checking for more data.
        +
        +
      • +
      + + + +
        +
      • +

        next

        +
        public char next()
        +          throws JSONException
        +
        Get the next character in the source string.
        +
        +
        Returns:
        +
        The next character, or 0 if past the end of the source string.
        +
        Throws:
        +
        JSONException - Thrown if there is an error reading the source string.
        +
        +
      • +
      + + + +
        +
      • +

        next

        +
        public char next(char c)
        +          throws JSONException
        +
        Consume the next character, and check that it matches a specified + character.
        +
        +
        Parameters:
        +
        c - The character to match.
        +
        Returns:
        +
        The character.
        +
        Throws:
        +
        JSONException - if the character does not match.
        +
        +
      • +
      + + + +
        +
      • +

        next

        +
        public String next(int n)
        +            throws JSONException
        +
        Get the next n characters.
        +
        +
        Parameters:
        +
        n - The number of characters to take.
        +
        Returns:
        +
        A string of n characters.
        +
        Throws:
        +
        JSONException - Substring bounds error if there are not + n characters remaining in the source string.
        +
        +
      • +
      + + + +
        +
      • +

        nextClean

        +
        public char nextClean()
        +               throws JSONException
        +
        Get the next char in the string, skipping whitespace.
        +
        +
        Returns:
        +
        A character, or 0 if there are no more characters.
        +
        Throws:
        +
        JSONException - Thrown if there is an error reading the source string.
        +
        +
      • +
      + + + +
        +
      • +

        nextString

        +
        public String nextString(char quote)
        +                  throws JSONException
        +
        Return the characters up to the next close quote character. + Backslash processing is done. The formal JSON format does not + allow strings in single quotes, but an implementation is allowed to + accept them.
        +
        +
        Parameters:
        +
        quote - The quoting character, either + " (double quote) or + ' (single quote).
        +
        Returns:
        +
        A String.
        +
        Throws:
        +
        JSONException - Unterminated string.
        +
        +
      • +
      + + + +
        +
      • +

        nextTo

        +
        public String nextTo(char delimiter)
        +              throws JSONException
        +
        Get the text up but not including the specified character or the + end of line, whichever comes first.
        +
        +
        Parameters:
        +
        delimiter - A delimiter character.
        +
        Returns:
        +
        A string.
        +
        Throws:
        +
        JSONException - Thrown if there is an error while searching + for the delimiter
        +
        +
      • +
      + + + +
        +
      • +

        nextTo

        +
        public String nextTo(String delimiters)
        +              throws JSONException
        +
        Get the text up but not including one of the specified delimiter + characters or the end of line, whichever comes first.
        +
        +
        Parameters:
        +
        delimiters - A set of delimiter characters.
        +
        Returns:
        +
        A string, trimmed.
        +
        Throws:
        +
        JSONException - Thrown if there is an error while searching + for the delimiter
        +
        +
      • +
      + + + +
        +
      • +

        nextValue

        +
        public Object nextValue()
        +                 throws JSONException
        +
        Get the next value. The value can be a Boolean, Double, Integer, + JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
        +
        +
        Returns:
        +
        An object.
        +
        Throws:
        +
        JSONException - If syntax error.
        +
        +
      • +
      + + + +
        +
      • +

        skipTo

        +
        public char skipTo(char to)
        +            throws JSONException
        +
        Skip characters until the next character is the requested character. + If the requested character is not found, no characters are skipped.
        +
        +
        Parameters:
        +
        to - A character to skip to.
        +
        Returns:
        +
        The requested character, or zero if the requested character + is not found.
        +
        Throws:
        +
        JSONException - Thrown if there is an error while searching + for the to character
        +
        +
      • +
      + + + +
        +
      • +

        syntaxError

        +
        public JSONException syntaxError(String message)
        +
        Make a JSONException to signal a syntax error.
        +
        +
        Parameters:
        +
        message - The error message.
        +
        Returns:
        +
        A JSONException object, suitable for throwing
        +
        +
      • +
      + + + +
        +
      • +

        syntaxError

        +
        public JSONException syntaxError(String message,
        +                                 Throwable causedBy)
        +
        Make a JSONException to signal a syntax error.
        +
        +
        Parameters:
        +
        message - The error message.
        +
        causedBy - The throwable that caused the error.
        +
        Returns:
        +
        A JSONException object, suitable for throwing
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Make a printable string of this JSONTokener.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        +
        " at {index} [character {character} line {line}]"
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/JSONWriter.html b/org/json/JSONWriter.html new file mode 100644 index 0000000..7f1648d --- /dev/null +++ b/org/json/JSONWriter.html @@ -0,0 +1,622 @@ + + + + + +JSONWriter + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class JSONWriter

+
+
+ +
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    JSONStringer
    +
    +
    +
    +
    public class JSONWriter
    +extends Object
    +
    JSONWriter provides a quick and convenient way of producing JSON text. + The texts produced strictly conform to JSON syntax rules. No whitespace is + added, so the results are ready for transmission or storage. Each instance of + JSONWriter can produce one JSON text. +

    + 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.

    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        mode

        +
        protected char mode
        +
        The current mode. Values: + 'a' (array), + 'd' (done), + 'i' (initial), + 'k' (key), + 'o' (object).
        +
      • +
      + + + +
        +
      • +

        writer

        +
        protected Appendable writer
        +
        The writer that will receive the output.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JSONWriter

        +
        public JSONWriter(Appendable w)
        +
        Make a fresh JSONWriter. It can be used to build one JSON text.
        +
        +
        Parameters:
        +
        w - an appendable object
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        array

        +
        public JSONWriter array()
        +                 throws JSONException
        +
        Begin appending a new array. All values until the balancing + endArray will be appended to this array. The + endArray method must be called to mark the array's end.
        +
        +
        Returns:
        +
        this
        +
        Throws:
        +
        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).
        +
        +
      • +
      + + + +
        +
      • +

        endArray

        +
        public JSONWriter endArray()
        +                    throws JSONException
        +
        End an array. This method most be called to balance calls to + array.
        +
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - If incorrectly nested.
        +
        +
      • +
      + + + +
        +
      • +

        endObject

        +
        public JSONWriter endObject()
        +                     throws JSONException
        +
        End an object. This method most be called to balance calls to + object.
        +
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - If incorrectly nested.
        +
        +
      • +
      + + + +
        +
      • +

        key

        +
        public JSONWriter key(String string)
        +               throws JSONException
        +
        Append a key. The key will be associated with the next value. In an + object, every value must be preceded by a key.
        +
        +
        Parameters:
        +
        string - A key string.
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - If the key is out of place. For example, keys + do not belong in arrays or if the key is null.
        +
        +
      • +
      + + + +
        +
      • +

        object

        +
        public JSONWriter object()
        +                  throws JSONException
        +
        Begin appending a new object. All keys and values until the balancing + endObject will be appended to this object. The + endObject method must be called to mark the object's end.
        +
        +
        Returns:
        +
        this
        +
        Throws:
        +
        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).
        +
        +
      • +
      + + + +
        +
      • +

        valueToString

        +
        public static String valueToString(Object value)
        +                            throws JSONException
        +
        Make a JSON text of an Object value. If the object has an + value.toJSONString() method, then that method will be used to produce the + JSON text. The method is required to produce a strictly conforming text. + If the object does not contain a toJSONString method (which is the most + common case), then a text will be produced by other means. If the value + is an array or Collection, then a JSONArray will be made from it and its + toJSONString method will be called. If the value is a MAP, then a + JSONObject will be made from it and its toJSONString method will be + called. Otherwise, the value's toString method will be called, and the + result will be quoted. + +

        + Warning: This method assumes that the data structure is acyclical.

        +
        +
        Parameters:
        +
        value - The value to be serialized.
        +
        Returns:
        +
        a printable, displayable, transmittable representation of the + object, beginning with { (left + brace) and ending with } (right + brace).
        +
        Throws:
        +
        JSONException - If the value is or contains an invalid number.
        +
        +
      • +
      + + + +
        +
      • +

        value

        +
        public JSONWriter value(boolean b)
        +                 throws JSONException
        +
        Append either the value true or the value + false.
        +
        +
        Parameters:
        +
        b - A boolean.
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      + + + +
        +
      • +

        value

        +
        public JSONWriter value(double d)
        +                 throws JSONException
        +
        Append a double value.
        +
        +
        Parameters:
        +
        d - A double.
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - If the number is not finite.
        +
        +
      • +
      + + + +
        +
      • +

        value

        +
        public JSONWriter value(long l)
        +                 throws JSONException
        +
        Append a long value.
        +
        +
        Parameters:
        +
        l - A long.
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      + + + +
        +
      • +

        value

        +
        public JSONWriter value(Object object)
        +                 throws JSONException
        +
        Append an object value.
        +
        +
        Parameters:
        +
        object - The object to append. It can be null, or a Boolean, Number, + String, JSONObject, or JSONArray, or an object that implements JSONString.
        +
        Returns:
        +
        this
        +
        Throws:
        +
        JSONException - If the value is out of sequence.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/Property.html b/org/json/Property.html new file mode 100644 index 0000000..b7f62f9 --- /dev/null +++ b/org/json/Property.html @@ -0,0 +1,305 @@ + + + + + +Property + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class Property

+
+
+ +
+
    +
  • +
    +
    +
    public class Property
    +extends Object
    +
    Converts a Property file data into JSONObject and back.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Property

        +
        public Property()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(Properties properties)
        +                               throws JSONException
        +
        Converts a property file object into a JSONObject. The property file object is a table of name value pairs.
        +
        +
        Parameters:
        +
        properties - java.util.Properties
        +
        Returns:
        +
        JSONObject
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      + + + +
        +
      • +

        toProperties

        +
        public static Properties toProperties(JSONObject jo)
        +                               throws JSONException
        +
        Converts the JSONObject into a property file object.
        +
        +
        Parameters:
        +
        jo - JSONObject
        +
        Returns:
        +
        java.util.Properties
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/XML.html b/org/json/XML.html new file mode 100644 index 0000000..f8726e6 --- /dev/null +++ b/org/json/XML.html @@ -0,0 +1,902 @@ + + + + + +XML + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class XML

+
+
+ +
+
    +
  • +
    +
    +
    public class XML
    +extends Object
    +
    This provides static methods to convert an XML text into a JSONObject, and to + covert a JSONObject into an XML text.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        AMP

        +
        public static final Character AMP
        +
        The Character '&'.
        +
      • +
      + + + +
        +
      • +

        APOS

        +
        public static final Character APOS
        +
        The Character '''.
        +
      • +
      + + + +
        +
      • +

        BANG

        +
        public static final Character BANG
        +
        The Character '!'.
        +
      • +
      + + + +
        +
      • +

        EQ

        +
        public static final Character EQ
        +
        The Character '='.
        +
      • +
      + + + +
        +
      • +

        GT

        +
        public static final Character GT
        +
        The Character
         '>'. 
        +
      • +
      + + + +
        +
      • +

        LT

        +
        public static final Character LT
        +
        The Character '<'.
        +
      • +
      + + + +
        +
      • +

        QUEST

        +
        public static final Character QUEST
        +
        The Character '?'.
        +
      • +
      + + + +
        +
      • +

        QUOT

        +
        public static final Character QUOT
        +
        The Character '"'.
        +
      • +
      + + + +
        +
      • +

        SLASH

        +
        public static final Character SLASH
        +
        The Character '/'.
        +
      • +
      + + + + + + + + +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XML

        +
        public XML()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        escape

        +
        public static String escape(String string)
        +
        Replace special characters with XML escapes: + +
         
        + &amp; (ampersand) is replaced by &amp;amp;
        + &lt; (less than) is replaced by &amp;lt;
        + &gt; (greater than) is replaced by &amp;gt;
        + &quot; (double quote) is replaced by &amp;quot;
        + &apos; (single quote / apostrophe) is replaced by &amp;apos;
        + 
        +
        +
        Parameters:
        +
        string - The string to be escaped.
        +
        Returns:
        +
        The escaped string.
        +
        +
      • +
      + + + +
        +
      • +

        unescape

        +
        public static String unescape(String string)
        +
        Removes XML escapes from the string.
        +
        +
        Parameters:
        +
        string - string to remove escapes from
        +
        Returns:
        +
        string with converted entities
        +
        +
      • +
      + + + +
        +
      • +

        noSpace

        +
        public static void noSpace(String string)
        +                    throws JSONException
        +
        Throw an exception if the string contains whitespace. Whitespace is not + allowed in tagNames and attributes.
        +
        +
        Parameters:
        +
        string - A string.
        +
        Throws:
        +
        JSONException - Thrown if the string contains whitespace or is empty.
        +
        +
      • +
      + + + +
        +
      • +

        stringToValue

        +
        public static Object stringToValue(String string,
        +                                   XMLXsiTypeConverter<?> typeConverter)
        +
        This method tries to convert the given string value to the target object
        +
        +
        Parameters:
        +
        string - String to convert
        +
        typeConverter - value converter to convert string to integer, boolean e.t.c
        +
        Returns:
        +
        JSON value of this string or the string
        +
        +
      • +
      + + + +
        +
      • +

        stringToValue

        +
        public static Object stringToValue(String string)
        +
        This method is the same as JSONObject.stringToValue(String).
        +
        +
        Parameters:
        +
        string - String to convert
        +
        Returns:
        +
        JSON value of this string or the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
         
        + &lt;[ [ ]]>
        + are ignored.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(Reader reader)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
         
        + &lt;[ [ ]]>
        + are ignored.
        +
        +
        Parameters:
        +
        reader - The XML source reader.
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(Reader reader,
        +                                      boolean keepStrings)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
        
        + &lt;[ [ ]]>
        + 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.
        +
        +
        Parameters:
        +
        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 strings
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(Reader reader,
        +                                      XMLParserConfiguration config)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
        
        + &lt;[ [ ]]>
        + 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.
        +
        +
        Parameters:
        +
        reader - The XML source reader.
        +
        config - Configuration options for the parser
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string,
        +                                      boolean keepStrings)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
         
        + &lt;[ [ ]]>
        + 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.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        keepStrings - If true, then values will not be coerced into boolean + or numeric values and will instead be left as strings
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toJSONObject

        +
        public static JSONObject toJSONObject(String string,
        +                                      XMLParserConfiguration config)
        +                               throws JSONException
        +
        Convert a well-formed (but not necessarily valid) XML string into a + JSONObject. Some information may be lost in this transformation because + JSON is a data format and XML is a document format. XML uses elements, + attributes, and content text, while JSON uses unordered collections of + name/value pairs and arrays of values. JSON does not does not like to + distinguish between elements and attributes. Sequences of similar + elements are represented as JSONArrays. Content text may be placed in a + "content" member. Comments, prologs, DTDs, and
         
        + &lt;[ [ ]]>
        + 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.
        +
        +
        Parameters:
        +
        string - The source string.
        +
        config - Configuration options for the parser.
        +
        Returns:
        +
        A JSONObject containing the structured data from the XML string.
        +
        Throws:
        +
        JSONException - Thrown if there is an errors while parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(Object object)
        +                       throws JSONException
        +
        Convert a JSONObject into a well-formed, element-normal XML string.
        +
        +
        Parameters:
        +
        object - A JSONObject.
        +
        Returns:
        +
        A string.
        +
        Throws:
        +
        JSONException - Thrown if there is an error parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(Object object,
        +                              String tagName)
        +
        Convert a JSONObject into a well-formed, element-normal XML string.
        +
        +
        Parameters:
        +
        object - A JSONObject.
        +
        tagName - The optional name of the enclosing tag.
        +
        Returns:
        +
        A string.
        +
        Throws:
        +
        JSONException - Thrown if there is an error parsing the string
        +
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(Object object,
        +                              String tagName,
        +                              XMLParserConfiguration config)
        +                       throws JSONException
        +
        Convert a JSONObject into a well-formed, element-normal XML string.
        +
        +
        Parameters:
        +
        object - A JSONObject.
        +
        tagName - The optional name of the enclosing tag.
        +
        config - Configuration that can control output to XML.
        +
        Returns:
        +
        A string.
        +
        Throws:
        +
        JSONException - Thrown if there is an error parsing the string
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/XMLParserConfiguration.html b/org/json/XMLParserConfiguration.html new file mode 100644 index 0000000..fbd9f6c --- /dev/null +++ b/org/json/XMLParserConfiguration.html @@ -0,0 +1,657 @@ + + + + + +XMLParserConfiguration + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class XMLParserConfiguration

+
+
+ +
+
    +
  • +
    +
    +
    public class XMLParserConfiguration
    +extends Object
    +
    Configuration object for the XML parser. The configuration is immutable.
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      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.
      +
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      protected XMLParserConfigurationclone() +
      Provides a new instance of the same configuration.
      +
      StringgetcDataTagName() +
      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
      +
      booleanisConvertNilAttributeToNull() +
      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)
      +
      booleanisKeepStrings() +
      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)
      +
      XMLParserConfigurationwithcDataTagName(String newVal) +
      The name of the key in a JSON Object that indicates a CDATA section.
      +
      XMLParserConfigurationwithConvertNilAttributeToNull(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)
      +
      XMLParserConfigurationwithKeepStrings(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)
      +
      XMLParserConfigurationwithXsiTypeMap(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
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        ORIGINAL

        +
        public static final XMLParserConfiguration ORIGINAL
        +
        Original Configuration of the XML Parser.
        +
      • +
      + + + +
        +
      • +

        KEEP_STRINGS

        +
        public static final XMLParserConfiguration KEEP_STRINGS
        +
        Original configuration of the XML Parser except that values are kept as strings.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XMLParserConfiguration

        +
        public XMLParserConfiguration()
        +
        Default parser configuration. Does not keep strings (tries to implicitly convert + values), and the CDATA Tag Name is "content".
        +
      • +
      + + + +
        +
      • +

        XMLParserConfiguration

        +
        @Deprecated
        +public 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.
        +
        Configure the parser string processing and use the default CDATA Tag Name as "content".
        +
        +
        Parameters:
        +
        keepStrings - true to parse all values as string. + false to try and convert XML string values into a JSON value.
        +
        +
      • +
      + + + +
        +
      • +

        XMLParserConfiguration

        +
        @Deprecated
        +public 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.
        +
        Configure the parser string processing to try and convert XML values to JSON values and + use the passed CDATA Tag Name the processing value. Pass null to + disable CDATA processing
        +
        +
        Parameters:
        +
        cDataTagNamenull - to disable CDATA processing. Any other value + to use that value as the JSONObject key name to process as CDATA.
        +
        +
      • +
      + + + +
        +
      • +

        XMLParserConfiguration

        +
        @Deprecated
        +public 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.
        +
        Configure the parser to use custom settings.
        +
        +
        Parameters:
        +
        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.
        +
        +
      • +
      + + + +
        +
      • +

        XMLParserConfiguration

        +
        @Deprecated
        +public 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.
        +
        Configure the parser to use custom settings.
        +
        +
        Parameters:
        +
        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}.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + + + + + +
        +
      • +

        isKeepStrings

        +
        public 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)
        +
        +
        Returns:
        +
        The keepStrings configuration value.
        +
        +
      • +
      + + + +
        +
      • +

        withKeepStrings

        +
        public 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)
        +
        +
        Parameters:
        +
        newVal - new value to use for the keepStrings configuration option.
        +
        Returns:
        +
        The existing configuration will not be modified. A new configuration is returned.
        +
        +
      • +
      + + + +
        +
      • +

        getcDataTagName

        +
        public String getcDataTagName()
        +
        The name of the key in a JSON Object that indicates a CDATA section. Historically this has + been the value "content" but can be changed. Use null to indicate no CDATA + processing.
        +
        +
        Returns:
        +
        The cDataTagName configuration value.
        +
        +
      • +
      + + + +
        +
      • +

        withcDataTagName

        +
        public XMLParserConfiguration withcDataTagName(String newVal)
        +
        The name of the key in a JSON Object that indicates a CDATA section. Historically this has + been the value "content" but can be changed. Use null to indicate no CDATA + processing.
        +
        +
        Parameters:
        +
        newVal - new value to use for the cDataTagName configuration option.
        +
        Returns:
        +
        The existing configuration will not be modified. A new configuration is returned.
        +
        +
      • +
      + + + +
        +
      • +

        isConvertNilAttributeToNull

        +
        public 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)
        +
        +
        Returns:
        +
        The convertNilAttributeToNull configuration value.
        +
        +
      • +
      + + + +
        +
      • +

        withConvertNilAttributeToNull

        +
        public 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)
        +
        +
        Parameters:
        +
        newVal - new value to use for the convertNilAttributeToNull configuration option.
        +
        Returns:
        +
        The existing configuration will not be modified. A new configuration is returned.
        +
        +
      • +
      + + + +
        +
      • +

        getXsiTypeMap

        +
        public 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
        +
        +
        Returns:
        +
        xsiTypeMap unmodifiable configuration map.
        +
        +
      • +
      + + + +
        +
      • +

        withXsiTypeMap

        +
        public 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
        +
        +
        Parameters:
        +
        xsiTypeMap - new HashMap<String, XMLXsiTypeConverter<?>>() to parse values with attribute + xsi:type="integer" as integer, xsi:type="string" as string
        +
        Returns:
        +
        The existing configuration will not be modified. A new configuration is returned.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/XMLTokener.html b/org/json/XMLTokener.html new file mode 100644 index 0000000..2798699 --- /dev/null +++ b/org/json/XMLTokener.html @@ -0,0 +1,494 @@ + + + + + +XMLTokener + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Class XMLTokener

+
+
+ +
+
    +
  • +
    +
    +
    public class XMLTokener
    +extends JSONTokener
    +
    The XMLTokener extends the JSONTokener to provide additional methods + for the parsing of XML texts.
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        entity

        +
        public static final HashMap<String,Character> entity
        +
        The table of entity values. It initially contains Character values for + amp, apos, gt, lt, quot.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XMLTokener

        +
        public XMLTokener(Reader r)
        +
        Construct an XMLTokener from a Reader.
        +
        +
        Parameters:
        +
        r - A source reader.
        +
        +
      • +
      + + + +
        +
      • +

        XMLTokener

        +
        public XMLTokener(String s)
        +
        Construct an XMLTokener from a string.
        +
        +
        Parameters:
        +
        s - A source string.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        nextCDATA

        +
        public String nextCDATA()
        +                 throws JSONException
        +
        Get the text in the CDATA block.
        +
        +
        Returns:
        +
        The string up to the ]]>.
        +
        Throws:
        +
        JSONException - If the ]]> is not found.
        +
        +
      • +
      + + + +
        +
      • +

        nextContent

        +
        public Object nextContent()
        +                   throws JSONException
        +
        Get the next XML outer token, trimming whitespace. There are two kinds + of tokens: the
         '<' 
        character which begins a markup + tag, and the content + text between markup tags.
        +
        +
        Returns:
        +
        A string, or a
         '<' 
        Character, or null if + there is no more source text.
        +
        Throws:
        +
        JSONException - if a called function has an error
        +
        +
      • +
      + + + +
        +
      • +

        nextEntity

        +
        public Object nextEntity(char ampersand)
        +                  throws JSONException
        +
        
        + Return the next entity. These entities are translated to Characters:
        +     &amp;  &apos;  &gt;  &lt;  &quot;.
        + 
        +
        +
        Parameters:
        +
        ampersand - An ampersand character.
        +
        Returns:
        +
        A Character or an entity String if the entity is not recognized.
        +
        Throws:
        +
        JSONException - If missing ';' in XML entity.
        +
        +
      • +
      + + + +
        +
      • +

        nextMeta

        +
        public Object nextMeta()
        +                throws JSONException
        +
         
        + Returns the next XML meta token. This is used for skipping over <!...>
        + and <?...?> structures.
        +  
        +
        +
        Returns:
        +
         Syntax characters (< > / = ! ?) are returned as
        +  Character, and strings and names are returned as Boolean. We don't care
        +  what the values actually are.
        +  
        +
        Throws:
        +
        JSONException - If a string is not properly closed or if the XML + is badly structured.
        +
        +
      • +
      + + + +
        +
      • +

        nextToken

        +
        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.
        + 
        +
        +
        Returns:
        +
        a String or a Character.
        +
        Throws:
        +
        JSONException - If the XML is not well formed.
        +
        +
      • +
      + + + +
        +
      • +

        skipPast

        +
        public void skipPast(String to)
        +
        Skip characters until past the requested string. + If it is not found, we are left at the end of the source with a result of false.
        +
        +
        Parameters:
        +
        to - A string to skip past.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/XMLXsiTypeConverter.html b/org/json/XMLXsiTypeConverter.html new file mode 100644 index 0000000..b29c83a --- /dev/null +++ b/org/json/XMLXsiTypeConverter.html @@ -0,0 +1,255 @@ + + + + + +XMLXsiTypeConverter + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.json
+

Interface XMLXsiTypeConverter<T>

+
+
+
+
    +
  • +
    +
    Type Parameters:
    +
    T - return type of convert method
    +
    +
    +
    +
    public interface XMLXsiTypeConverter<T>
    +
    Type conversion configuration interface to be used with xsi:type attributes. +
    + 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>() {
    +          &#64;Override public String convert(final String value) {
    +              return value;
    +          }
    +      });
    +      xsiTypeMap.put("integer", new XMLXsiTypeConverter<Integer>() {
    +          &#64;Override public Integer convert(final String value) {
    +              return Integer.valueOf(value);
    +          }
    +      });
    + 
    + 
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        convert

        +
        T convert(String value)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/org/json/package-frame.html b/org/json/package-frame.html new file mode 100644 index 0000000..49421d9 --- /dev/null +++ b/org/json/package-frame.html @@ -0,0 +1,51 @@ + + + + + +org.json + + + + + +

org.json

+
+

Interfaces

+ +

Classes

+ +

Exceptions

+ +

Annotation Types

+ +
+ + diff --git a/org/json/package-summary.html b/org/json/package-summary.html new file mode 100644 index 0000000..e929e40 --- /dev/null +++ b/org/json/package-summary.html @@ -0,0 +1,314 @@ + + + + + +org.json + + + + + + + + +
+ + + + + + + +
+ + +
+

Package org.json

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/org/json/package-tree.html b/org/json/package-tree.html new file mode 100644 index 0000000..b1a0566 --- /dev/null +++ b/org/json/package-tree.html @@ -0,0 +1,178 @@ + + + + + +org.json Class Hierarchy + + + + + + + + +
+ + + + + + + +
+ + +
+

Hierarchy For Package org.json

+
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +

Annotation Type Hierarchy

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/overview-tree.html b/overview-tree.html index 5b74593..3c64ed0 100644 --- a/overview-tree.html +++ b/overview-tree.html @@ -2,7 +2,7 @@ - + Class Hierarchy diff --git a/serialized-form.html b/serialized-form.html index 4d3d6ba..f2c8a7a 100644 --- a/serialized-form.html +++ b/serialized-form.html @@ -2,7 +2,7 @@ - + Serialized Form