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

Numbers as strings #799

Closed
tomba opened this issue Oct 25, 2017 · 1 comment
Closed

Numbers as strings #799

tomba opened this issue Oct 25, 2017 · 1 comment

Comments

@tomba
Copy link

tomba commented Oct 25, 2017

Hi,

Is there a way to get the json data in its original string format? The problem is that the following code:

	auto j = json::parse("[ 0.1 ]");

	auto& v = j.at(0);

	stringstream ss;
	ss << fixed << setprecision(50) << v.get<double>();
	string str = ss.str();

produces:

"0.10000000000000000555111512312578270211815834045410"

Being able to get the original string data would fix the floating point problems and also allow handling of integer numbers larger than 64 bit.

@nlohmann
Copy link
Owner

No, this is currently not possible. In the future, the type of the floating-point numbers should be configurable, so such an extension could be possible.

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

2 participants