toJSONArray

open fun toJSONArray(string: String): JSONArray

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.

Return

A JSONArray containing the structured data from the XML string.

Parameters

string

The source string.

Throws

Thrown on error converting to a JSONArray


open fun toJSONArray(string: String, keepStrings: Boolean): JSONArray

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

<[ [ ]]>
are ignored.

Return

A JSONArray containing the structured data from the XML string.

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

Throws

Thrown on error converting to a JSONArray


open fun toJSONArray(x: XMLTokener, keepStrings: Boolean): JSONArray

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

<[ [ ]]>
are ignored.

Return

A JSONArray containing the structured data from the XML string.

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

Throws

Thrown on error converting to a JSONArray


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.

Return

A JSONArray containing the structured data from the XML string.

Parameters

x

An XMLTokener.

Throws

Thrown on error converting to a JSONArray