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?
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?
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,
but for future features may be useful that [] operator (that is very readable code) can be return null json object.
Sometime when the key doesnt exist it's useful have a default value and dont use find then read and so on or catch exception.
i.e.
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: