fix string value parameter

This commit is contained in:
gb 2022-12-31 11:50:15 +08:00
parent d464c09d2c
commit d1f0cbf5a7
2 changed files with 4 additions and 4 deletions

View File

@ -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);
}

View File

@ -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