-
-
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
Type Conversion #779
Comments
The library does not provide such conversions. You may need something like #include "json.hpp"
using json = nlohmann::json;
int main()
{
json j = {{"number", "9"}};
int i = std::stoi(j["number"].get_ref<std::string&>());
} |
Thank you for the quick response. Great library. |
I have one more question. What is the difference between?:
They all seem to do the same thing and return a reference. |
Then |
So, what will tmp be, string& or string?: |
This is a copy,
|
So |
They always return a reference, which is then copied if you don't use |
Can I close this issue? |
💤 I closed this issue due to inactivity. Please feel free to add a comment and I shall reopen it. |
@nlohmann what would be the proper way to solve this, Or there is something better, that leaves autogenerating with |
Is there a way to convert a string value to a number value or vice versa?
For example:
I figured this word work, but it doesn't:
j.at( "number" ).get<int>();
Do I just have to grab it as a string and convert myself, or is there a better way?
The text was updated successfully, but these errors were encountered: