diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 1b002ddb5..960d92e20 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -236,7 +236,10 @@ template::value, int> = 0> void to_json(BasicJsonType& j, const CompatibleString& s) { - j.m_value.destroy(j.m_type); + if (!j.is_null()) + { + j = nullptr; + } external_constructor::construct(j, s); }