@@ -280,6 +280,55 @@ public static JSONArray toJSONArray(String string, boolean keepStrings) throws J
280280 }
281281
282282
283+
284+ /**
285+ * Convert a well-formed (but not necessarily valid) XML string into a
286+ * JSONArray using the JsonML transform. Each XML tag is represented as
287+ * a JSONArray in which the first element is the tag name. If the tag has
288+ * attributes, then the second element will be JSONObject containing the
289+ * name/value pairs. If the tag contains children, then strings and
290+ * JSONArrays will represent the child tags.
291+ * As opposed to toJSONArray this method does not attempt to convert
292+ * any text node or attribute value to any type
293+ * but just leaves it as a string.
294+ * Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
295+ * @param string The source string.
296+ * @param config The XML parser configuration:
297+ * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
298+ * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
299+ * or numeric values and will instead be left as strings
300+ * @return A JSONArray containing the structured data from the XML string.
301+ * @throws JSONException Thrown on error converting to a JSONArray
302+ */
303+ public static JSONArray toJSONArray (String string , XMLtoJSONMLParserConfiguration config ) throws JSONException {
304+ return (JSONArray )parse (new XMLTokener (string ), true , null , config , 0 );
305+ }
306+
307+
308+ /**
309+ * Convert a well-formed (but not necessarily valid) XML string into a
310+ * JSONArray using the JsonML transform. Each XML tag is represented as
311+ * a JSONArray in which the first element is the tag name. If the tag has
312+ * attributes, then the second element will be JSONObject containing the
313+ * name/value pairs. If the tag contains children, then strings and
314+ * JSONArrays will represent the child content and tags.
315+ * As opposed to toJSONArray this method does not attempt to convert
316+ * any text node or attribute value to any type
317+ * but just leaves it as a string.
318+ * Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
319+ * @param x An XMLTokener.
320+ * @param config The XML parser configuration:
321+ * XMLtoJSONMLParserConfiguration.ORIGINAL is the default behaviour;
322+ * XMLtoJSONMLParserConfiguration.KEEP_STRINGS means values will not be coerced into boolean
323+ * or numeric values and will instead be left as strings
324+ * @return A JSONArray containing the structured data from the XML string.
325+ * @throws JSONException Thrown on error converting to a JSONArray
326+ */
327+ public static JSONArray toJSONArray (XMLTokener x , XMLtoJSONMLParserConfiguration config ) throws JSONException {
328+ return (JSONArray )parse (x , true , null , config , 0 );
329+ }
330+
331+
283332 /**
284333 * Convert a well-formed (but not necessarily valid) XML string into a
285334 * JSONArray using the JsonML transform. Each XML tag is represented as
0 commit comments