mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Showing issue of illegal node names with possible underscore-replacement. (Will currently assterted to an Exception).
This commit is contained in:
parent
16fa69c0f6
commit
5eadebb797
1 changed files with 21 additions and 0 deletions
21
XMLTest.java
21
XMLTest.java
|
@ -294,4 +294,25 @@ public class XMLTest {
|
||||||
JSONObject expectedJsonObject = XML.toJSONObject(expectedStr);
|
JSONObject expectedJsonObject = XML.toJSONObject(expectedStr);
|
||||||
Util.compareActualVsExpectedJsonObjects(finalJsonObject,expectedJsonObject);
|
Util.compareActualVsExpectedJsonObjects(finalJsonObject,expectedJsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Illegal node-names must be converted to legal XML-node-names.
|
||||||
|
* The given example shows 2 nodes which are valid for JSON, but not for XML.
|
||||||
|
* Therefore illegal arguments should be converted to e.g. an underscore (_).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldHandleIllegalJSONNodeNames()
|
||||||
|
{
|
||||||
|
JSONObject inputJSON = new JSONObject();
|
||||||
|
inputJSON.append("123IllegalNode", "someValue1");
|
||||||
|
inputJSON.append("Illegal@node", "someValue2");
|
||||||
|
|
||||||
|
String result = XML.toString(inputJSON);
|
||||||
|
|
||||||
|
String expected = "<___IllegalNode>someValue1</___IllegalNode><Illegal_node>someValue3</Illegal_node>";
|
||||||
|
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue