@@ -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 "
@@ -957,11 +957,71 @@ void xmlToJson() {
957957 @ Test
958958 void xmlToJson2 () {
959959 assertEquals (
960- "{\n " + " \" debug\" : \" &\" \n " + " }" ,
960+ "{\n \" debug\" : \" &\" \n }" ,
961961 U .xmlToJson (
962962 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <debug>&amp;</debug>" ));
963963 }
964964
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+
9651025 @ Test
9661026 void xmlOrJsonToJson () {
9671027 assertEquals (
@@ -977,7 +1037,7 @@ void xmlOrJsonToJson() {
9771037 U .xmlOrJsonToJson (
9781038 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
9791039 + "<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}" ));
9811041 assertEquals ("[\n ]" , U .xmlOrJsonToJson ("[]" ));
9821042 assertEquals ("" , U .xmlOrJsonToJson ("" ));
9831043 }
@@ -992,7 +1052,7 @@ void xmlOrJsonToXml() {
9921052 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
9931053 + "<root empty-array=\" true\" ></root>" ));
9941054 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>" ,
9961056 U .xmlOrJsonToXml ("{\" a\" :1}" ));
9971057 assertEquals (
9981058 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
@@ -1041,7 +1101,7 @@ void renameMapKey() {
10411101 map .put ("-self-closing" , "false" );
10421102 U .rename (map , "test" , "test1" );
10431103 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 ));
10451105 Map <String , Object > map2 = new LinkedHashMap <>();
10461106 List <Object > list = new ArrayList <>();
10471107 list .add (new ArrayList <Object >());
@@ -1192,7 +1252,7 @@ void updateMapKey() {
11921252 map .put ("-self-closing" , "false" );
11931253 U .rename (map , "test" , "test1" );
11941254 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 ));
11961256 Map <String , Object > map2 = new LinkedHashMap <>();
11971257 List <Object > list = new ArrayList <>();
11981258 list .add (new ArrayList <Object >());
@@ -1214,7 +1274,7 @@ void setValue() {
12141274 map .put ("-self-closing" , "false" );
12151275 U .setValue (map , "test" , "test1" );
12161276 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 ));
12181278 Map <String , Object > map2 = new LinkedHashMap <>();
12191279 List <Object > list = new ArrayList <>();
12201280 list .add (new ArrayList <Object >());
@@ -2109,7 +2169,7 @@ class Customer {
21092169 void issue306 () {
21102170 String json =
21112171 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 );
21132173 }
21142174
21152175 @ Test
0 commit comments