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
If I try to access a Json object values for a missing key - we expect it to throw an exception. However when the json object has const qualiifer, it asserts and does not throw an exception. Not sure whether it's by design or i'm missing anything obvious here.
What is the issue you have?
If I try to access a Json object values for a missing key - we expect it to throw an exception. However when the json object has const qualiifer, it asserts and does not throw an exception. Not sure whether it's by design or i'm missing anything obvious here.
Please describe the steps to reproduce the issue.
You can find the code-example here:
https://wandbox.org/permlink/KQ8vwhM4tbINbZsz
Can you provide a small but working code example?
What is the expected behavior?
The const json objects should also throw the exceptions if they are searched for missing key values.
And what is the actual behavior instead?
The program aborts
prog.exe: /opt/wandbox/nlohmann-json/include/nlohmann/json.hpp:3898: const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value_type& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::operator[](T*) const [with T = const char; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::const_reference = const nlohmann::basic_json<>&]: Assertion
m_value.object->find(key) != m_value.object->end()' failed.`
Which compiler and operating system are you using?
Which version of the library did you use?
develop
branchIf you experience a compilation error: can you compile and run the unit tests?
The text was updated successfully, but these errors were encountered: