diff --git a/common/json/json.cpp b/common/json/json.cpp index 70c0ff2..e8ae93f 100644 --- a/common/json/json.cpp +++ b/common/json/json.cpp @@ -514,7 +514,7 @@ bool json::set_value(const char* key, double val) return true; } -bool json::set_value(const char* key, std::string val) +bool json::set_value(const char* key, const char* val) { if (type_ != VAL_TYPE_OBJECT) return false; @@ -526,12 +526,12 @@ bool json::set_value(const char* key, std::string val) child->clear(); child->type_ = VAL_TYPE_STRING; child->key() = key ? key : ""; - child->strval_ = val; + child->strval_ = val ? val : ""; child->release(); } else { - child = new json(key, val.c_str()); + child = new json(key, val); arr_val_.push_back(child); } diff --git a/common/json/json.h b/common/json/json.h index 5167955..8b63b3b 100644 --- a/common/json/json.h +++ b/common/json/json.h @@ -111,7 +111,7 @@ public: bool set_value(const char* key, bool val); bool set_value(const char* key, int val); bool set_value(const char* key, double val); - bool set_value(const char* key, std::string val); + bool set_value(const char* key, const char* val); bool set_value(const char* key, json* val); // operator+= only for array