diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 9d7f55fc9..1b002ddb5 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -236,6 +236,7 @@ template::value, int> = 0> void to_json(BasicJsonType& j, const CompatibleString& s) { + j.m_value.destroy(j.m_type); external_constructor::construct(j, s); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 7ed12f19a..601b28a06 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4694,6 +4694,7 @@ template::value, int> = 0> void to_json(BasicJsonType& j, const CompatibleString& s) { + j.m_value.destroy(j.m_type); external_constructor::construct(j, s); }