Package org.json
Class JSONML
- java.lang.Object
- 
- org.json.JSONML
 
- 
 public class JSONML extends java.lang.ObjectThis 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 SummaryConstructors Constructor Description JSONML()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static JSONArraytoJSONArray(java.lang.String string)Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform.static JSONArraytoJSONArray(XMLTokener x)Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform.static JSONObjecttoJSONObject(java.lang.String string)Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform.static JSONObjecttoJSONObject(XMLTokener x)Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform.static java.lang.StringtoString(JSONArray ja)Reverse the JSONML transformation, making an XML text from a JSONArray.static java.lang.StringtoString(JSONObject jo)Reverse the JSONML transformation, making an XML text from a JSONObject.
 
- 
- 
- 
Method Detail- 
toJSONArraypublic static JSONArray toJSONArray(java.lang.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<[ [ ]]>are ignored.- Parameters:
- string- The source string.
- Returns:
- A JSONArray containing the structured data from the XML string.
- Throws:
- JSONException
 
 - 
toJSONArraypublic 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<[ [ ]]>are ignored.- Parameters:
- x- An XMLTokener.
- Returns:
- A JSONArray containing the structured data from the XML string.
- Throws:
- JSONException
 
 - 
toJSONObjectpublic 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 <[ [ ]]>are ignored.- Parameters:
- x- An XMLTokener of the XML source text.
- Returns:
- A JSONObject containing the structured data from the XML string.
- Throws:
- JSONException
 
 - 
toJSONObjectpublic static JSONObject toJSONObject(java.lang.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 <[ [ ]]>are ignored.- Parameters:
- string- The XML source text.
- Returns:
- A JSONObject containing the structured data from the XML string.
- Throws:
- JSONException
 
 - 
toStringpublic static java.lang.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
 
 - 
toStringpublic static java.lang.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
 
 
- 
 
-