Skip to content
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

optLong vs getLong inconsistencies #783

Merged
merged 4 commits into from
Oct 13, 2023
Merged

Conversation

rudrajyotib
Copy link
Contributor

For exponential decimal conversion, number is not touched. Leading zeros removed from numeric number strings before converting to number.

For exponential decimal conversion, number is not touched.
Leading zeros removed from numeric number strings before converting to number.
@stleary stleary changed the title #653 - optLong vs getLong inconsistencies optLong vs getLong inconsistencies Oct 7, 2023
@stleary
Copy link
Owner

stleary commented Oct 7, 2023

What problem does this code solve?
optLong() and getLong() may produce different results depending on whether leading zeros are present in the value being retrieved.

Risks
Low

Changes to the API?
Yes. stringToNumber() behavior was modified. This may change how the calling methods behave when the value contains leading zeros. It is not believed that this will be a common occurrence.

Will this require a new release?
No

Should the documentation be updated?
No

Does it break the unit tests?
No. New unit tests were added.

Was any code refactored in this commit?
Minimal refactoring of existing code was done (parameter name change, etc)

Review status
APPROVED

Starting 3-day comment window.

src/main/java/org/json/JSONObject.java Outdated Show resolved Hide resolved
src/main/java/org/json/JSONObject.java Outdated Show resolved Hide resolved
@stleary
Copy link
Owner

stleary commented Oct 9, 2023

Merge pending resolution of comments.

src/main/java/org/json/JSONObject.java Outdated Show resolved Hide resolved
src/main/java/org/json/JSONObject.java Show resolved Hide resolved
src/main/java/org/json/JSONObject.java Outdated Show resolved Hide resolved
@rudrajyotib
Copy link
Contributor Author

@stleary @johnjaylward - can you review the latest commits please.

Copy link
Contributor

@johnjaylward johnjaylward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good now I think. @stleary if we want to maintain similar processing for XML, these changes will need to be copied over to the XML class

@stleary
Copy link
Owner

stleary commented Oct 13, 2023

@rudrajyotib Nice work addressing the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants