@@ -94,6 +94,7 @@ public class U<T> extends Underscore<T> {
9494 private static final String LOWER = "[a-z\\ xdf-\\ xf6\\ xf8-\\ xff]+" ;
9595 private static final String SELF_CLOSING = "-self-closing" ;
9696 private static final String NIL_KEY = "-nil" ;
97+ private static final String OMIT_XML_DECL = "#omit-xml-declaration" ;
9798 private static final java .util .regex .Pattern RE_WORDS =
9899 java .util .regex .Pattern .compile (
99100 UPPER
@@ -2749,6 +2750,20 @@ public static String xmlToJson(String xml) {
27492750 return xmlToJson (xml , Json .JsonStringBuilder .Step .TWO_SPACES , null );
27502751 }
27512752
2753+ @ SuppressWarnings ("unchecked" )
2754+ public static String xmlToJsonMinimum (String xml , Json .JsonStringBuilder .Step identStep ) {
2755+ Object object = Xml .fromXml (xml );
2756+ if (object instanceof Map ) {
2757+ ((Map ) object ).remove (OMIT_XML_DECL );
2758+ return Json .toJson (replaceSelfClosingWithEmpty ((Map ) object ), identStep );
2759+ }
2760+ return Json .toJson ((List ) object , identStep );
2761+ }
2762+
2763+ public static String xmlToJsonMinimum (String xml ) {
2764+ return xmlToJsonMinimum (xml , Json .JsonStringBuilder .Step .TWO_SPACES );
2765+ }
2766+
27522767 public static String xmlToJson (String xml , Json .JsonStringBuilder .Step identStep ) {
27532768 return xmlToJson (xml , identStep , null );
27542769 }
@@ -2885,7 +2900,7 @@ public static Map<String, Object> removeMinusesAndConvertNumbers(Map<String, Obj
28852900 newKey = entry .getKey ();
28862901 }
28872902 if (!entry .getKey ().equals (SELF_CLOSING )
2888- && !entry .getKey ().equals ("#omit-xml-declaration" )) {
2903+ && !entry .getKey ().equals (OMIT_XML_DECL )) {
28892904 outMap .put (newKey , makeObject (entry .getValue ()));
28902905 }
28912906 }
0 commit comments