File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -294,4 +294,25 @@ public void shouldHandleNestedArraytoString() {
294294 JSONObject expectedJsonObject = XML .toJSONObject (expectedStr );
295295 Util .compareActualVsExpectedJsonObjects (finalJsonObject ,expectedJsonObject );
296296 }
297+
298+
299+ /**
300+ * Illegal node-names must be converted to legal XML-node-names.
301+ * The given example shows 2 nodes which are valid for JSON, but not for XML.
302+ * Therefore illegal arguments should be converted to e.g. an underscore (_).
303+ *
304+ */
305+ @ Test
306+ public void shouldHandleIllegalJSONNodeNames ()
307+ {
308+ JSONObject inputJSON = new JSONObject ();
309+ inputJSON .append ("123IllegalNode" , "someValue1" );
310+ inputJSON .append ("Illegal@node" , "someValue2" );
311+
312+ String result = XML .toString (inputJSON );
313+
314+ String expected = "<___IllegalNode>someValue1</___IllegalNode><Illegal_node>someValue3</Illegal_node>" ;
315+
316+ assertEquals (expected , result );
317+ }
297318}
You can’t perform that action at this time.
0 commit comments