diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 16bf6af00..af54f1b16 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3609,8 +3609,10 @@ class basic_json #endif m_value.array->resize(idx + 1); +#if JSON_DIAGNOSTICS // set parent for values added above set_parents(begin() + previous_size, idx + 1 - previous_size); +#endif } return m_value.array->operator[](idx); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 7617b8eda..ab3d857c2 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20364,8 +20364,10 @@ class basic_json #endif m_value.array->resize(idx + 1); +#if JSON_DIAGNOSTICS // set parent for values added above set_parents(begin() + previous_size, idx + 1 - previous_size); +#endif } return m_value.array->operator[](idx);