@@ -871,7 +871,7 @@ void xmlToJson() {
871
871
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
872
872
+ "<root empty-array=\" true\" ></root>" ));
873
873
assertEquals (
874
- "{\n " + " \" a\" : null,\n " + " \" #omit-xml-declaration\" : \" yes\" \n " + " }" ,
874
+ "{\n \" a\" : null,\n \" #omit-xml-declaration\" : \" yes\" \n }" ,
875
875
U .xmlToJson ("<a/>" , U .XmlToJsonMode .REPLACE_SELF_CLOSING_WITH_NULL ));
876
876
assertEquals (
877
877
"{\n "
@@ -897,7 +897,7 @@ void xmlToJson() {
897
897
"<c><b></b><b></b><a/></c>" ,
898
898
U .XmlToJsonMode .REPLACE_EMPTY_TAG_WITH_STRING ));
899
899
assertEquals (
900
- "{\n " + " \" a\" : \" \" ,\n " + " \" #omit-xml-declaration\" : \" yes\" \n " + " }" ,
900
+ "{\n \" a\" : \" \" ,\n \" #omit-xml-declaration\" : \" yes\" \n }" ,
901
901
U .xmlToJson ("<a/>" , U .XmlToJsonMode .REPLACE_SELF_CLOSING_WITH_STRING ));
902
902
assertEquals (
903
903
"{\n "
@@ -954,6 +954,14 @@ void xmlToJson() {
954
954
U .replaceEmptyValueWithEmptyString (map4 );
955
955
}
956
956
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
+
957
965
@ Test
958
966
void xmpToJson3 () {
959
967
Map <String , Object > map2 = new LinkedHashMap <>();
@@ -988,11 +996,30 @@ void xmpToJson3() {
988
996
}
989
997
990
998
@ Test
991
- void xmlToJson2 () {
999
+ void xmpToJson4 () {
992
1000
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
+ + "}" ,
994
1014
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>" ));
996
1023
}
997
1024
998
1025
@ Test
@@ -1010,7 +1037,7 @@ void xmlOrJsonToJson() {
1010
1037
U .xmlOrJsonToJson (
1011
1038
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1012
1039
+ "<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}" ));
1014
1041
assertEquals ("[\n ]" , U .xmlOrJsonToJson ("[]" ));
1015
1042
assertEquals ("" , U .xmlOrJsonToJson ("" ));
1016
1043
}
@@ -1025,7 +1052,7 @@ void xmlOrJsonToXml() {
1025
1052
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1026
1053
+ "<root empty-array=\" true\" ></root>" ));
1027
1054
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>" ,
1029
1056
U .xmlOrJsonToXml ("{\" a\" :1}" ));
1030
1057
assertEquals (
1031
1058
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
@@ -1074,7 +1101,7 @@ void renameMapKey() {
1074
1101
map .put ("-self-closing" , "false" );
1075
1102
U .rename (map , "test" , "test1" );
1076
1103
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 ));
1078
1105
Map <String , Object > map2 = new LinkedHashMap <>();
1079
1106
List <Object > list = new ArrayList <>();
1080
1107
list .add (new ArrayList <Object >());
@@ -1225,7 +1252,7 @@ void updateMapKey() {
1225
1252
map .put ("-self-closing" , "false" );
1226
1253
U .rename (map , "test" , "test1" );
1227
1254
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 ));
1229
1256
Map <String , Object > map2 = new LinkedHashMap <>();
1230
1257
List <Object > list = new ArrayList <>();
1231
1258
list .add (new ArrayList <Object >());
@@ -1247,7 +1274,7 @@ void setValue() {
1247
1274
map .put ("-self-closing" , "false" );
1248
1275
U .setValue (map , "test" , "test1" );
1249
1276
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 ));
1251
1278
Map <String , Object > map2 = new LinkedHashMap <>();
1252
1279
List <Object > list = new ArrayList <>();
1253
1280
list .add (new ArrayList <Object >());
@@ -2142,7 +2169,7 @@ class Customer {
2142
2169
void issue306 () {
2143
2170
String json =
2144
2171
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 );
2146
2173
}
2147
2174
2148
2175
@ Test
0 commit comments