-
-
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
Assertion failed on ["NoExistKey"] of an not existing key of const json& #825
Comments
This is the expected behavior. See the first note in the README. The code contains numerous debug assertions which can be switched off by defining the preprocessor macro NDEBUG, see the documentation of assert. In particular, note operator[] implements unchecked access for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an assertion failure if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the at() function. |
Thank you I will change my code, json a ... read from file void readObj (const json& r2a) Dont you ? |
Bug Report
What is the issue you have?
If you try to assign a key (that dosnt exist) from a const json& to const json& or json an assert is fire :
"Assertion `m_value.object->find(key) != m_value.object->end()' failed"
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
``
``
What is the expected behavior?
If 'b' is const json& a reference to.
If 'b' is json a copy of x, in that case a null json.
And what is the actual behavior instead?
"Assertion `m_value.object->find(key) != m_value.object->end()' failed"
Which compiler and operating system are you using? Is it a supported compiler?
VS2015 on W10
https://wandbox.org/
Best regards
Paolo
The text was updated successfully, but these errors were encountered: