This provides static methods to convert an XML text into a JSONObject, and to covert a JSONObject into an XML text.
More...
Static Public Member Functions |
static String | escape (String string) |
| Replace special characters with XML escapes:
|
static JSONObject | toJSONObject (String string) throws ParseException |
| Convert a well-formed (but not necessarily valid) XML string into a JSONObject.
|
static String | toString (Object o) |
| Convert a JSONObject into a well-formed XML string.
|
static String | toString (Object o, String tagName) |
| Convert a JSONObject into a well-formed XML string.
|
Static Public Attributes |
static final Character | AMP = new Character('&') |
| The Character '&'.
|
static final Character | APOS = new Character('\'') |
| The Character '''.
|
static final Character | BANG = new Character('!') |
| The Character '!'.
|
static final Character | EQ = new Character('=') |
| The Character '='.
|
static final Character | GT = new Character('>') |
| The Character '>'.
|
static final Character | LT = new Character('<') |
| The Character '<'.
|
static final Character | QUEST = new Character('?') |
| The Character '?'.
|
static final Character | QUOT = new Character('"') |
| The Character '"'.
|
static final Character | SLASH = new Character('/') |
| The 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
- 0.1
Member Function Documentation
static String org.json.XML.escape |
( |
String |
string | ) |
|
|
static |
Replace special characters with XML escapes:
& is replaced by &
< is replaced by <
> is replaced by >
" is replaced by "
- Parameters
-
string | The string to be escaped. |
- Returns
- The escaped string.
Referenced by org.json.XML.toString().
static JSONObject org.json.XML.toJSONObject |
( |
String |
string | ) |
throws ParseException |
|
static |
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
-
- Returns
- A JSONObject containing the structured data from the XML string.
- Exceptions
-
References org.json.JSONTokener.more(), and org.json.JSONTokener.skipPast().
Referenced by org.json.Test.main().
static String org.json.XML.toString |
( |
Object |
o | ) |
|
|
static |
static String org.json.XML.toString |
( |
Object |
o, |
|
|
String |
tagName |
|
) |
| |
|
static |
Member Data Documentation
final Character org.json.XML.AMP = new Character('&') |
|
static |
final Character org.json.XML.APOS = new Character('\'') |
|
static |
final Character org.json.XML.BANG = new Character('!') |
|
static |
final Character org.json.XML.EQ = new Character('=') |
|
static |
final Character org.json.XML.GT = new Character('>') |
|
static |
final Character org.json.XML.LT = new Character('<') |
|
static |
final Character org.json.XML.QUEST = new Character('?') |
|
static |
final Character org.json.XML.QUOT = new Character('"') |
|
static |
final Character org.json.XML.SLASH = new Character('/') |
|
static |
The documentation for this class was generated from the following file: