-
-
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
Unexpected behaviour of is_null #1112
Comments
By the way, the following works as expected: nlohmann::json l = nlohmann::json::object();
if (l.empty()) {
std::cout << "Object is also empty" << std::endl;
}
if (l.is_null()) {
std::cout << "Object is also null" << std::endl;
} If all of this is intended to work like this: sorry for the hassle and please, feel free to silently delete this issue. |
Please note:
In your second example, I do not believe that |
Yes, indeed, is_null does not evaluate to true here, this is what I meant with 'works as expected'. |
No worries - every ticket may be helpful for others and give me an idea what needs to be documented more thoroughly. |
The following code produces unexpected output (which is, all four statements being printed):
I am not entirely sure whether or not this is the expected behaviour, but I think it would be more intuitive to have only the empty() conditions evaluate to true and the others to false?
Best wishes and thanks for the great work!
The text was updated successfully, but these errors were encountered: