@@ -996,7 +996,7 @@ public static String toXml(Map map) {
996996 }
997997
998998 @ SuppressWarnings ("unchecked" )
999- private static Object getValue (final Object value , final FromType fromType ) {
999+ private static Object getValue (final String name , final Object value , final FromType fromType ) {
10001000 final Object localValue ;
10011001 if (value instanceof Map && ((Map <String , Object >) value ).entrySet ().size () == 1 ) {
10021002 final Map .Entry <String , Object > entry = ((Map <String , Object >) value ).entrySet ().iterator ().next ();
@@ -1009,7 +1009,8 @@ private static Object getValue(final Object value, final FromType fromType) {
10091009 } else {
10101010 localValue = value ;
10111011 }
1012- return localValue instanceof String ? XmlValue .unescape ((String ) localValue ) : localValue ;
1012+ return localValue instanceof String && name .startsWith ("-" )
1013+ ? XmlValue .unescape ((String ) localValue ) : localValue ;
10131014 }
10141015
10151016 public static Object stringToNumber (String number ) {
@@ -1105,9 +1106,9 @@ private static Object checkArray(final Map<String, Object> map, final String nam
11051106 localMap4 .remove (ARRAY );
11061107 localMap4 .remove (SELF_CLOSING );
11071108 object = name .equals (XmlValue .getMapKey (localMap4 ))
1108- ? U .newArrayList (Collections .singletonList (getValue (XmlValue .getMapValue (localMap4 ),
1109+ ? U .newArrayList (Collections .singletonList (getValue (name , XmlValue .getMapValue (localMap4 ),
11091110 FromType .FOR_CONVERT )))
1110- : U .newArrayList (Collections .singletonList (getValue (localMap4 , FromType .FOR_CONVERT )));
1111+ : U .newArrayList (Collections .singletonList (getValue (name , localMap4 , FromType .FOR_CONVERT )));
11111112 } else {
11121113 object = localMap ;
11131114 }
@@ -1256,13 +1257,13 @@ private static void addNodeValue(final Map<String, Object> map, final String nam
12561257 final String elementName = unescapeName (elementMapper .apply (name , namespaces ));
12571258 if (map .containsKey (elementName )) {
12581259 if (TEXT .equals (elementName )) {
1259- map .put (elementName + uniqueIds [0 ], nodeMapper .apply (getValue (value , fromType )));
1260+ map .put (elementName + uniqueIds [0 ], nodeMapper .apply (getValue (name , value , fromType )));
12601261 uniqueIds [0 ] += 1 ;
12611262 } else if (COMMENT .equals (elementName )) {
1262- map .put (elementName + uniqueIds [1 ], nodeMapper .apply (getValue (value , fromType )));
1263+ map .put (elementName + uniqueIds [1 ], nodeMapper .apply (getValue (name , value , fromType )));
12631264 uniqueIds [1 ] += 1 ;
12641265 } else if (CDATA .equals (elementName )) {
1265- map .put (elementName + uniqueIds [2 ], nodeMapper .apply (getValue (value , fromType )));
1266+ map .put (elementName + uniqueIds [2 ], nodeMapper .apply (getValue (name , value , fromType )));
12661267 uniqueIds [2 ] += 1 ;
12671268 } else {
12681269 final Object object = map .get (elementName );
@@ -1277,7 +1278,7 @@ private static void addNodeValue(final Map<String, Object> map, final String nam
12771278 }
12781279 } else {
12791280 if (elementName != null ) {
1280- map .put (elementName , nodeMapper .apply (getValue (value , fromType )));
1281+ map .put (elementName , nodeMapper .apply (getValue (name , value , fromType )));
12811282 }
12821283 }
12831284 }
@@ -1298,7 +1299,7 @@ private static void addText(final Map<String, Object> map, final String name, fi
12981299 objects .add (index , item );
12991300 lastIndex -= 1 ;
13001301 }
1301- final Object newValue = getValue (value , fromType );
1302+ final Object newValue = getValue (name , value , fromType );
13021303 if (newValue instanceof List ) {
13031304 objects .add (((List ) newValue ).get (0 ));
13041305 } else {
0 commit comments