使用rapidjson时,编译器提示出错,显示的是"Parameter type mismatch:Expression must be lvalue",用的编译器是clion,代码如下:
std::string Body_Json(const std::map<std::string, std::string> body)
{
rapidjson::Document json;
json.SetObject();
for (auto m : body)
{
json.AddMember(rapidjson::StringRef(m.first.c_str()),
(Value)rapidjson::StringRef(m.second.c_str()),
json.GetAllocator());
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> write(buffer);
json.Accept(write);
return buffer.GetString();
}
在"rapidjson::StringRef(m.first.c _ str()),(Value)rapidjson::StringRef(m.second.c _ str()),"这两句时会报错,但编译没有问题,程序可以运行,虽然可以忽略这个问题,但还是怕会出现问题,希望有大神能帮忙解答下.