@@ -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 "
@@ -957,11 +957,71 @@ void xmlToJson() {
957
957
@ Test
958
958
void xmlToJson2 () {
959
959
assertEquals (
960
- "{\n " + " \" debug\" : \" &\" \n " + " }" ,
960
+ "{\n \" debug\" : \" &\" \n }" ,
961
961
U .xmlToJson (
962
962
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <debug>&amp;</debug>" ));
963
963
}
964
964
965
+ @ Test
966
+ void xmpToJson3 () {
967
+ Map <String , Object > map2 = new LinkedHashMap <>();
968
+ List <Object > list = new ArrayList <>();
969
+ list .add (new ArrayList <Object >());
970
+ map2 .put ("list" , list );
971
+ U .replaceMinusWithAt (map2 );
972
+ assertEquals (
973
+ "{\n "
974
+ + " \" a\" : {\n "
975
+ + " \" @c\" : \" 1\" ,\n "
976
+ + " \" b\" : [\n "
977
+ + " {\n "
978
+ + " },\n "
979
+ + " {\n "
980
+ + " }\n "
981
+ + " ]\n "
982
+ + " },\n "
983
+ + " \" #omit-xml-declaration\" : \" yes\" \n "
984
+ + "}" ,
985
+ U .xmlToJson (
986
+ "<a c=\" 1\" ><b></b><b></b></a>" , U .XmlToJsonMode .REPLACE_MINUS_WITH_AT ));
987
+ Map <String , Object > map3 = new LinkedHashMap <>();
988
+ List <Object > list2 = new ArrayList <>();
989
+ list2 .add (new ArrayList <Object >());
990
+ map3 .put ("list" , list2 );
991
+ U .replaceMinusWithAt (map3 );
992
+ U .replaceMinusWithAt (null );
993
+ U .xmlToJson (
994
+ "<a c=\" 1\" ><b></b><b></b></a>" ,
995
+ U .XmlToJsonMode .REPLACE_EMPTY_TAG_WITH_NULL_AND_MINUS_WITH_AT );
996
+ }
997
+
998
+ @ Test
999
+ void xmpToJson4 () {
1000
+ assertEquals (
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
+ + "}" ,
1014
+ U .xmlToJson (
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>" ));
1023
+ }
1024
+
965
1025
@ Test
966
1026
void xmlOrJsonToJson () {
967
1027
assertEquals (
@@ -977,7 +1037,7 @@ void xmlOrJsonToJson() {
977
1037
U .xmlOrJsonToJson (
978
1038
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
979
1039
+ "<root empty-array=\" true\" ></root>" ));
980
- assertEquals ("{\n " + " \" a\" : 1\n " + " }" , U .xmlOrJsonToJson ("{\" a\" :1}" ));
1040
+ assertEquals ("{\n \" a\" : 1\n }" , U .xmlOrJsonToJson ("{\" a\" :1}" ));
981
1041
assertEquals ("[\n ]" , U .xmlOrJsonToJson ("[]" ));
982
1042
assertEquals ("" , U .xmlOrJsonToJson ("" ));
983
1043
}
@@ -992,7 +1052,7 @@ void xmlOrJsonToXml() {
992
1052
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
993
1053
+ "<root empty-array=\" true\" ></root>" ));
994
1054
assertEquals (
995
- "<?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>" ,
996
1056
U .xmlOrJsonToXml ("{\" a\" :1}" ));
997
1057
assertEquals (
998
1058
"<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
@@ -1041,7 +1101,7 @@ void renameMapKey() {
1041
1101
map .put ("-self-closing" , "false" );
1042
1102
U .rename (map , "test" , "test1" );
1043
1103
Map <String , Object > newMap = U .rename (map , "-self-closing" , "-self-closing1" );
1044
- assertEquals ("{\n " + " \" -self-closing1\" : \" false\" \n " + " }" , U .toJson (newMap ));
1104
+ assertEquals ("{\n \" -self-closing1\" : \" false\" \n }" , U .toJson (newMap ));
1045
1105
Map <String , Object > map2 = new LinkedHashMap <>();
1046
1106
List <Object > list = new ArrayList <>();
1047
1107
list .add (new ArrayList <Object >());
@@ -1192,7 +1252,7 @@ void updateMapKey() {
1192
1252
map .put ("-self-closing" , "false" );
1193
1253
U .rename (map , "test" , "test1" );
1194
1254
Map <String , Object > newMap = U .update (map , map );
1195
- assertEquals ("{\n " + " \" -self-closing\" : \" false\" \n " + " }" , U .toJson (newMap ));
1255
+ assertEquals ("{\n \" -self-closing\" : \" false\" \n }" , U .toJson (newMap ));
1196
1256
Map <String , Object > map2 = new LinkedHashMap <>();
1197
1257
List <Object > list = new ArrayList <>();
1198
1258
list .add (new ArrayList <Object >());
@@ -1214,7 +1274,7 @@ void setValue() {
1214
1274
map .put ("-self-closing" , "false" );
1215
1275
U .setValue (map , "test" , "test1" );
1216
1276
Map <String , Object > newMap = U .setValue (map , "-self-closing" , "true" );
1217
- assertEquals ("{\n " + " \" -self-closing\" : \" true\" \n " + " }" , U .toJson (newMap ));
1277
+ assertEquals ("{\n \" -self-closing\" : \" true\" \n }" , U .toJson (newMap ));
1218
1278
Map <String , Object > map2 = new LinkedHashMap <>();
1219
1279
List <Object > list = new ArrayList <>();
1220
1280
list .add (new ArrayList <Object >());
@@ -2109,7 +2169,7 @@ class Customer {
2109
2169
void issue306 () {
2110
2170
String json =
2111
2171
U .objectBuilder ().add ("firstName" , "John" ).add ("lastName" , (Object ) null ).toJson ();
2112
- assertEquals ("{\n \" firstName\" : \" John\" ,\n " + " \" lastName\" : null\n " + " }" , json );
2172
+ assertEquals ("{\n \" firstName\" : \" John\" ,\n \" lastName\" : null\n }" , json );
2113
2173
}
2114
2174
2115
2175
@ Test
0 commit comments