-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
convert json value to std::string??? #1061
Comments
What did you try? Was there an error message? Did you have a look at the README? |
thanks for replay sir.... json jk; json jsd; string str=jk; want to use 'jk' value as string.... |
From README
|
Can I close this issue? |
@nlohmann Probably not, looks like case with operator= messed up: json fail = R"({"foo": "bar"})"_json;
// std::string barExpected;`
// barExpected = fail["foo"]; // fails
std::string barExpected = fail["foo"]; //works |
@AOrazaev I cannot reproduce the error. Which compiler are you using? What is the error message? |
Maybe like this?
|
@rue-ryuzaki Yep, I've worked around this like you said. @nlohmann I compiled example from VS2017.
Code I used to reproduce:
|
And if insead of:
Use:
It will fail in developer cmd with cl.exe too. complaining about
|
@AOrazaev Your issue seems not related to the original comment. |
@AOrazaev For #1061 (comment), using JsonWrapper(const json& obj)
: _foo(obj["foo"].get<std::string>())
{} works though. |
I mean, probably topic starter tried his example in VS and hit issue I described before. I personally worked around everything with |
@Mamlesh Can I close this issue? |
Thanks to nlohmann/json#1061 Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
how to convert json value to string ..
The text was updated successfully, but these errors were encountered: