diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 960d92e20..a0ca4211a 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -238,7 +238,7 @@ void to_json(BasicJsonType& j, const CompatibleString& s) { if (!j.is_null()) { - j = nullptr; + j = BasicJsonType(); } external_constructor::construct(j, s); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 219a6a480..4bdadd871 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4696,7 +4696,7 @@ void to_json(BasicJsonType& j, const CompatibleString& s) { if (!j.is_null()) { - j = nullptr; + j = BasicJsonType(); } external_constructor::construct(j, s); }