-
Notifications
You must be signed in to change notification settings - Fork 2.6k
XML optLong/getLong equivalent updates for string to number conversion. #794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7b2677a
1d0775c
2374766
04a4c5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -733,7 +733,7 @@ public void contentOperations() { | |
| @Test | ||
| public void testToJSONArray_jsonOutput() { | ||
| final String originalXml = "<root><id>01</id><id>1</id><id>00</id><id>0</id><item id=\"01\"/><title>True</title></root>"; | ||
| final JSONObject expected = new JSONObject("{\"root\":{\"item\":{\"id\":\"01\"},\"id\":[\"01\",1,\"00\",0],\"title\":true}}"); | ||
| final JSONObject expected = new JSONObject("{\"root\":{\"item\":{\"id\":1},\"id\":[1,1,0,0],\"title\":true}}"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not remove existing test cases.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @stleary - hese test cases were misleading. In the expected JSON string, the numbers still had preceding zeros. If we want the values to be treated as numbers, the leading zeros should go. In fact, the test comment also confirms that. |
||
| final JSONObject actualJsonOutput = XML.toJSONObject(originalXml, | ||
| new XMLParserConfiguration().withKeepStrings(false)); | ||
| Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expected); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -791,7 +791,7 @@ private void compareFileToJSONObject(String xmlStr, String expectedStr) { | |
| @Test | ||
| public void testToJSONArray_jsonOutput() { | ||
| final String originalXml = "<root><id>01</id><id>1</id><id>00</id><id>0</id><item id=\"01\"/><title>True</title></root>"; | ||
| final JSONObject expectedJson = new JSONObject("{\"root\":{\"item\":{\"id\":\"01\"},\"id\":[\"01\",1,\"00\",0],\"title\":true}}"); | ||
| final JSONObject expectedJson = new JSONObject("{\"root\":{\"item\":{\"id\":1},\"id\":[1,1,0,0],\"title\":true}}"); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not remove existing test cases.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @stleary - hese test cases were misleading. In the expected JSON string, the numbers still had preceding zeros. If we want the values to be treated as numbers, the leading zeros should go. In fact, the test comment also confirms that. |
||
| final JSONObject actualJsonOutput = XML.toJSONObject(originalXml, false); | ||
|
|
||
| Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expectedJson); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.