org.json.XML Class Reference
List of all members.
Static Public Member Functions |
| static String | escape (String string) |
| static void | noSpace (String string) throws JSONException |
| static JSONObject | toJSONObject (String string) throws JSONException |
| static String | toString (Object o) throws JSONException |
| static String | toString (Object o, String tagName) throws JSONException |
Static Public Attributes |
| static final Character | AMP = new Character('&') |
| static final Character | APOS = new Character('\'') |
| static final Character | BANG = new Character('!') |
| static final Character | EQ = new Character('=') |
| static final Character | GT = new Character('>') |
| static final Character | LT = new Character('<') |
| static final Character | QUEST = new Character('?') |
| static final Character | QUOT = new Character('"') |
| static final Character | SLASH = new Character('/') |
Detailed Description
This provides static methods to convert an XML text into a JSONObject, and to covert a JSONObject into an XML text.
- Author:
- JSON.org
- Version:
- 2010-04-08
Member Function Documentation
| static String org.json.XML.escape |
( |
String |
string |
) |
[static] |
Replace special characters with XML escapes:
& (ampersand) is replaced by &
< (less than) is replaced by <
> (greater than) is replaced by >
" (double quote) is replaced by "
- Parameters:
-
| string | The string to be escaped. |
- Returns:
- The escaped string.
| static void org.json.XML.noSpace |
( |
String |
string |
) |
throws JSONException [static] |
Throw an exception if the string contains whitespace. Whitespace is not allowed in tagNames and attributes.
- Parameters:
-
- Exceptions:
-
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 <[ [ ]]> are ignored.
- Parameters:
-
| string | The source string. |
- Returns:
- A JSONObject containing the structured data from the XML string.
- Exceptions:
-
| static String org.json.XML.toString |
( |
Object |
o, |
|
|
String |
tagName | |
|
) |
| | throws JSONException [static] |
Convert a JSONObject into a well-formed, element-normal XML string.
- Parameters:
-
| o | A JSONObject. |
| tagName | The optional name of the enclosing tag. |
- Returns:
- A string.
- Exceptions:
-
| static String org.json.XML.toString |
( |
Object |
o |
) |
throws JSONException [static] |
Convert a JSONObject into a well-formed, element-normal XML string.
- Parameters:
-
- Returns:
- A string.
- Exceptions:
-
Member Data Documentation