-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
reading int number and string number #1986
Comments
What is your exact issue? Deserialization (also know as parsing) is described here: https://github.com/nlohmann/json#serialization--deserialization |
my problem is that json jp = R"({"state": "10"})"_json;
int state = jp["state"]; // return 0 instead of value 10
json jp = R"({"state": 10})"_json;
int state = jp["state"]; // return 10 becuase it is number not string |
You can call |
I know that. I am looking for an easier way instead of checking types for every number type in json. what about |
The library does not provide such conversions. |
Hi. I receive a JSON from 2 different places that contain a number. one of them returns JSON with a number and the other returns the same JSON with a number with quotes. like this:
{"state": 0}
or:
{"state": "0"}
the problem is how can I read them with no problem?
The text was updated successfully, but these errors were encountered: