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

doubles are printed as integers #454

Closed
RiccardoRossi opened this issue Feb 15, 2017 · 3 comments
Closed

doubles are printed as integers #454

RiccardoRossi opened this issue Feb 15, 2017 · 3 comments

Comments

@RiccardoRossi
Copy link

Hello,
i am having some trouble with my tests.

thing is that when if I read the string
{"bool_value":true,"double_value":2.0,"int_value":10,"level1":{"list_value":[3,"hi",false],"tmp":5.0},"string_value":"hello"}

and i print it back, i get
{"bool_value":true,"double_value":2,"int_value":10,"level1":{"list_value":[3,"hi",false],"tmp":5},"string_value":"hello"}

where both "double_value" and "tmp" are written back as integers instead of double. This is an issue as when i read them back in next time they will be considered integers instead of doubles (floats).

same issue also happens with "dump(4)" instead of "dump()"

is there a way to preserve the type upon printing?

regards
Riccardo

@TurpentineDistillery
Copy link

This is #362.

@nlohmann
Copy link
Owner

I can confirm the bug - it should indeed be fixed with #362. I shall have a look at this this weekend.

nlohmann added a commit that referenced this issue Feb 16, 2017
@nlohmann
Copy link
Owner

Merged #378 with 4151f2d. This fixes #362 and #454.

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

No branches or pull requests

3 participants