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

-0 parsed as string!!! #318

Closed
metwp opened this issue Feb 15, 2017 · 4 comments
Closed

-0 parsed as string!!! #318

metwp opened this issue Feb 15, 2017 · 4 comments

Comments

@metwp
Copy link

metwp commented Feb 15, 2017

If I parse the following JSON string, the value of key "a" will be interpreted as an integer. So far, so good.
But unfortunately the value of key "b" will be interpreted as a string and NOT as a number (integer).

{ "a": 0, "b": -0 }

Is there a possibility to avoid this behaviour, or do I'm something wrong?

@erosb
Copy link
Contributor

erosb commented Feb 15, 2017

What version of the library are you using? AFAIR it has been fixed already.

@johnjaylward
Copy link
Contributor

this was fixed over a year ago unless there is a regression:
#188

@johnjaylward
Copy link
Contributor

@metwp the -0 should return as a Double, not an Integer since java Integer does not maintain -0, it would flip to +0.

@metwp
Copy link
Author

metwp commented Feb 16, 2017

Thanks for your immediate answers.

@erosb
Version of JSONObject.java is from 2014-05-03.

@johnjaylward
It seams, I have to update the version.
Conversion to Double is also fine.

@metwp metwp closed this as completed Feb 16, 2017
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

No branches or pull requests

3 participants