assertion_failure: single_include/nlohmann/json.hpp:18670: void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::assert_invariant(bool) const [with 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>]: Assertion `!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j) { return j.m_parent == this; })' failed.
Inserting into arrays using
j_array[index] = value;syntax does not correctly update the parents and will trigger the assertion for parent correctness further down the line.Please describe the steps to reproduce the issue.
Minimal example:
This produces the following assertion error when the copying from
j_arraytoj_array_copyis performed:Which compiler and operating system are you using?
Which version of the library did you use?
developbranchIf you experience a compilation error: can you compile and run the unit tests?