We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
According to the document for "JSON for Modern C++", when the variable type is "std::nullptr_t", it returns "null".
It's a silly question, but if assigning "nullptr" to "std::string" like "Example", which one is intended as the specification?
(1) it causes the segmentation fault by undefined behavior of std::string (2) it returns "null" as same as "std::nullptr_t"
It seems that (1) is the specification: it's undesired to assign "nullptr" to "std::string". Is it correct about my understanding?
[Example] #include <iostream> #include <nlohmann/json.hpp> int main() { nlohmann::json j; std::string value = nullptr; j[ "value" ] = value; std::cout << j << std::endl; ... }
The text was updated successfully, but these errors were encountered:
I do not fully understand the issue. If you want to store the JSON value null at key "value", then it's sufficient to write
null
"value"
j[ "value" ] = nullptr;
There is no need to have a std::string involved.
std::string
Sorry, something went wrong.
Thank you for the polite answer to store the JSON value "null" . Please close this question.
No branches or pull requests
Question
According to the document for "JSON for Modern C++", when the variable type is "std::nullptr_t", it returns "null".
It's a silly question, but if assigning "nullptr" to "std::string" like "Example", which one is intended as the specification?
(1) it causes the segmentation fault by undefined behavior of std::string
(2) it returns "null" as same as "std::nullptr_t"
It seems that (1) is the specification: it's undesired to assign "nullptr" to "std::string".
Is it correct about my understanding?
Version
The text was updated successfully, but these errors were encountered: