-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
XML optLong/getLong equivalent updates for string to number conversion. #794
Conversation
Moved the code logic to a common utility to de-duplicate.
@@ -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}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove existing test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
@@ -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}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove existing test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
|
Closed due to failing existing unit tests. |
@rudrajyotib Sorry about that, should not have closed this PR. It still needs work. For example, if a unit test must be broken, call it out and provide a convincing explanation about why it was necessary. Also, I would strongly discourage refactoring large amounts of code. It's better to have duplicate code at first, and then refactor it in a later PR. |
@stleary - can you please add the Hacktoberfest tag back. I have reverted all changes that combined feature and refactor. We can now apply the changes one by one. |
@stleary - new implementation breaks some existing test cases. This test case being broken is the expected behavior, in my opinion. I have pushed these changes with duplicate code. |
For now the code remains duplicated in JSON and XML parsers. Unit test cases updated to comply with number expectations.
@rudrajyotib , There has been a lot of PRs merged to master today. Please do a merge or rebase to get the latest changes. |
@stleary - now synced and merged with master. |
What problem does this code solve? Does the code still compile with Java6? Risks Changes to the API? Will this require a new release? Should the documentation be updated? Does it break the unit tests? Was any code refactored in this commit? Review status Starting 3-day comment window |
@stleary - can you please keep the hacktoberfest-accepted label. |
@rudrajyotib I will update your PRs, but I don't think it's necessary since all accepted PRs get an approving review. I only keep the hacktoberfest label for internal tracking. From the website: |
[stleary update]: See #790
Moved the code logic to a common utility to de-duplicate.