You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the issue you have?
I get an exception when I do an implicit conversion and then read a value.
I read here that json = string should work.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
using json = nlohmann::json;
string str = R"({"happy": true,"pi": 3.141})";
// if I replace it with "json js = json::parse(str.c_str());", it works!
json js = str;
// this returns ""[json.exception.type_error.305] cannot use operator[] with a string argument with string"
auto v1 = js["happy"].get<bool>();
Which compiler and operating system are you using? Is it a supported compiler?
VS2017
Did you use a released version of the library or the version from the develop branch?
develop, tried also the latest release and happens also
Maybe I am doing something wrong? I am evaluating this project to replace cjson and I hope that I will make the switch. 👍
Thank you
The text was updated successfully, but these errors were encountered:
By calling json js = str;, you are not parsing the string to a JSON value, but create a JSON value that holds that string. For that reason, calling js["happy"] makes no sense, as js is a string and not an object, hence the exception.
The README says that you can do the following:
// create a JSON value from a string
json j = "Hello";
// create a string from a JSON value
string s = j;
What is the issue you have?
I get an exception when I do an implicit conversion and then read a value.
I read here that
json = string
should work.Please describe the steps to reproduce the issue. Can you provide a small but working code example?
Which compiler and operating system are you using? Is it a supported compiler?
VS2017
Did you use a released version of the library or the version from the
develop
branch?develop, tried also the latest release and happens also
Maybe I am doing something wrong? I am evaluating this project to replace
cjson
and I hope that I will make the switch. 👍Thank you
The text was updated successfully, but these errors were encountered: