@@ -871,7 +871,7 @@ void xmlToJson() {
871871 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
872872 + "<root empty-array=\" true\" ></root>" ));
873873 assertEquals (
874- "{\n " + " \" a\" : null,\n " + " \" #omit-xml-declaration\" : \" yes\" \n " + " }" ,
874+ "{\n \" a\" : null,\n \" #omit-xml-declaration\" : \" yes\" \n }" ,
875875 U .xmlToJson ("<a/>" , U .XmlToJsonMode .REPLACE_SELF_CLOSING_WITH_NULL ));
876876 assertEquals (
877877 "{\n "
@@ -897,7 +897,7 @@ void xmlToJson() {
897897 "<c><b></b><b></b><a/></c>" ,
898898 U .XmlToJsonMode .REPLACE_EMPTY_TAG_WITH_STRING ));
899899 assertEquals (
900- "{\n " + " \" a\" : \" \" ,\n " + " \" #omit-xml-declaration\" : \" yes\" \n " + " }" ,
900+ "{\n \" a\" : \" \" ,\n \" #omit-xml-declaration\" : \" yes\" \n }" ,
901901 U .xmlToJson ("<a/>" , U .XmlToJsonMode .REPLACE_SELF_CLOSING_WITH_STRING ));
902902 assertEquals (
903903 "{\n "
@@ -954,6 +954,14 @@ void xmlToJson() {
954954 U .replaceEmptyValueWithEmptyString (map4 );
955955 }
956956
957+ @ Test
958+ void xmlToJson2 () {
959+ assertEquals (
960+ "{\n \" debug\" : \" &\" \n }" ,
961+ U .xmlToJson (
962+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <debug>&amp;</debug>" ));
963+ }
964+
957965 @ Test
958966 void xmpToJson3 () {
959967 Map <String , Object > map2 = new LinkedHashMap <>();
@@ -988,11 +996,30 @@ void xmpToJson3() {
988996 }
989997
990998 @ Test
991- void xmlToJson2 () {
999+ void xmpToJson4 () {
9921000 assertEquals (
993- "{\n " + " \" debug\" : \" &\" \n " + "}" ,
1001+ "{\n "
1002+ + " \" z:catalog\" : {\n "
1003+ + " \" -xmlns:xsi\" : \" http://www.w3.org/2001/XMLSchema-instance\" ,\n "
1004+ + " \" -xmlns:z\" : \" www.microsoft.com/zzz\" ,\n "
1005+ + " \" book\" : {\n "
1006+ + " \" -xsi:noNamespaceSchemaLocation\" : \" http://www.example.com/MyData.xsd\" ,\n "
1007+ + " \" -id\" : \" bk101\" ,\n "
1008+ + " \" title\" : \" Presenting XML\" ,\n "
1009+ + " \" author\" : \" Richard Light\" \n "
1010+ + " }\n "
1011+ + " },\n "
1012+ + " \" #omit-xml-declaration\" : \" yes\" \n "
1013+ + "}" ,
9941014 U .xmlToJson (
995- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <debug>&amp;</debug>" ));
1015+ "<z:catalog xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
1016+ + "xmlns:z=\" www.microsoft.com/zzz\" >\n "
1017+ + " <book xsi:noNamespaceSchemaLocation=\" http://www.example.com/MyData.xsd\" \r \n "
1018+ + " id=\" bk101\" >\n "
1019+ + " <title>Presenting XML</title>\n "
1020+ + " <author>Richard Light</author>\n "
1021+ + " </book>\n "
1022+ + "</z:catalog>" ));
9961023 }
9971024
9981025 @ Test
@@ -1010,7 +1037,7 @@ void xmlOrJsonToJson() {
10101037 U .xmlOrJsonToJson (
10111038 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
10121039 + "<root empty-array=\" true\" ></root>" ));
1013- assertEquals ("{\n " + " \" a\" : 1\n " + " }" , U .xmlOrJsonToJson ("{\" a\" :1}" ));
1040+ assertEquals ("{\n \" a\" : 1\n }" , U .xmlOrJsonToJson ("{\" a\" :1}" ));
10141041 assertEquals ("[\n ]" , U .xmlOrJsonToJson ("[]" ));
10151042 assertEquals ("" , U .xmlOrJsonToJson ("" ));
10161043 }
@@ -1025,7 +1052,7 @@ void xmlOrJsonToXml() {
10251052 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
10261053 + "<root empty-array=\" true\" ></root>" ));
10271054 assertEquals (
1028- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " + " <a number=\" true\" >1</a>" ,
1055+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <a number=\" true\" >1</a>" ,
10291056 U .xmlOrJsonToXml ("{\" a\" :1}" ));
10301057 assertEquals (
10311058 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
@@ -1074,7 +1101,7 @@ void renameMapKey() {
10741101 map .put ("-self-closing" , "false" );
10751102 U .rename (map , "test" , "test1" );
10761103 Map <String , Object > newMap = U .rename (map , "-self-closing" , "-self-closing1" );
1077- assertEquals ("{\n " + " \" -self-closing1\" : \" false\" \n " + " }" , U .toJson (newMap ));
1104+ assertEquals ("{\n \" -self-closing1\" : \" false\" \n }" , U .toJson (newMap ));
10781105 Map <String , Object > map2 = new LinkedHashMap <>();
10791106 List <Object > list = new ArrayList <>();
10801107 list .add (new ArrayList <Object >());
@@ -1225,7 +1252,7 @@ void updateMapKey() {
12251252 map .put ("-self-closing" , "false" );
12261253 U .rename (map , "test" , "test1" );
12271254 Map <String , Object > newMap = U .update (map , map );
1228- assertEquals ("{\n " + " \" -self-closing\" : \" false\" \n " + " }" , U .toJson (newMap ));
1255+ assertEquals ("{\n \" -self-closing\" : \" false\" \n }" , U .toJson (newMap ));
12291256 Map <String , Object > map2 = new LinkedHashMap <>();
12301257 List <Object > list = new ArrayList <>();
12311258 list .add (new ArrayList <Object >());
@@ -1247,7 +1274,7 @@ void setValue() {
12471274 map .put ("-self-closing" , "false" );
12481275 U .setValue (map , "test" , "test1" );
12491276 Map <String , Object > newMap = U .setValue (map , "-self-closing" , "true" );
1250- assertEquals ("{\n " + " \" -self-closing\" : \" true\" \n " + " }" , U .toJson (newMap ));
1277+ assertEquals ("{\n \" -self-closing\" : \" true\" \n }" , U .toJson (newMap ));
12511278 Map <String , Object > map2 = new LinkedHashMap <>();
12521279 List <Object > list = new ArrayList <>();
12531280 list .add (new ArrayList <Object >());
@@ -2142,7 +2169,7 @@ class Customer {
21422169 void issue306 () {
21432170 String json =
21442171 U .objectBuilder ().add ("firstName" , "John" ).add ("lastName" , (Object ) null ).toJson ();
2145- assertEquals ("{\n \" firstName\" : \" John\" ,\n " + " \" lastName\" : null\n " + " }" , json );
2172+ assertEquals ("{\n \" firstName\" : \" John\" ,\n \" lastName\" : null\n }" , json );
21462173 }
21472174
21482175 @ Test
0 commit comments