Skip to content

Fixed incorrect cast getting float from array - #604

Merged
stleary merged 1 commit into
stleary:masterfrom
ianlovejoy:master
May 1, 2021
Merged

stleary merged 1 commit into
stleary:masterfrom
ianlovejoy:master

Conversation

@ianlovejoy

Copy link
Copy Markdown
Contributor

Hello,

I noticed that if a double is added to a JSONArray and then retrieved with getFloat(), a class cast exception was raised. This case is handled correctly by JSONObject (as opposed to array).

The root cause turned out to be an incorrect cast. I corrected the cast and also added a test for this case. I tried to closely follow the existing coding conventions as well as the corresponding code in JSONObject.

Please let me know if you need any more information. Thanks for maintaining this project!

Sincerely,
Ian Lovejoy

Added test for getting float from array
@ianlovejoy

Copy link
Copy Markdown
Contributor Author

@johnjaylward thanks for approving these changes, it appears that there is a workflow awaiting approval as well since I am a first-time contributor, not sure if you can unstick that as well? Thanks!

@stleary

stleary commented Apr 29, 2021 •

Copy link
Copy Markdown
Owner

What problem does this code solve?
Exception when calling getFloat() for a valid value.

Risks
Low

Changes to the API?
No

Will this require a new release?
No

Should the documentation be updated?
No

Does it break the unit tests?
No

Was any code refactored in this commit?
No

Review status
APPROVED

@stleary

stleary commented Apr 29, 2021

Copy link
Copy Markdown
Owner

Starting 3-day comment window.

@johnjaylward

Copy link
Copy Markdown
Contributor

There is a new test @stleary

@stleary

stleary commented Apr 29, 2021

Copy link
Copy Markdown
Owner

Thanks @johnjaylward I saw the test but just didn't read it closely. Review updated.

#readthecode

@stleary
stleary merged commit 143db39 into stleary:master May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants