MCPcopy Create free account
hub / github.com/VolmitSoftware/Adapt / toJSONObject

Method toJSONObject

src/main/java/com/volmit/adapt/util/XML.java:361–368  ·  view source on GitHub ↗

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 a

(String string)

Source from the content-addressed store, hash-verified

359 * @return A JSONObject containing the structured data from the XML string.
360 */
361 public static JSONObject toJSONObject(String string) throws JSONException {
362 JSONObject jo = new JSONObject();
363 XMLTokener x = new XMLTokener(string);
364 while (x.more() && x.skipPast("<")) {
365 parse(x, jo, null);
366 }
367 return jo;
368 }
369
370 /**
371 * Convert a JSONObject into a well-formed, element-normal XML string.

Callers

nothing calls this directly

Calls 3

skipPastMethod · 0.95
parseMethod · 0.95
moreMethod · 0.80

Tested by

no test coverage detected