diff --git a/src/json.hpp b/src/json.hpp index 595f5b2d2..186632f5b 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3800,7 +3800,8 @@ struct hash inline size_t operator()(const nlohmann::json& j) const { // a naive hashing via the string representation - return hash()(j.dump()); + const auto& h = hash(); + return h(j.dump()); } }; } @@ -3815,7 +3816,8 @@ no parse error occurred. */ inline nlohmann::json operator "" _json(const char* s, std::size_t) { - return nlohmann::json::parse(s); + return nlohmann::json::parse(reinterpret_cast + (const_cast(s))); } #endif diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 4f718bbaf..31d77c6ba 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -3149,7 +3149,8 @@ struct hash inline size_t operator()(const nlohmann::json& j) const { // a naive hashing via the string representation - return hash()(j.dump()); + const auto& h = hash(); + return h(j.dump()); } }; } @@ -3164,7 +3165,8 @@ no parse error occurred. */ inline nlohmann::json operator "" _json(const char* s, std::size_t) { - return nlohmann::json::parse(s); + return nlohmann::json::parse(reinterpret_cast + (const_cast(s))); } #endif