我试图比较rapidjson文档,但它给出了一个错误消息,我不知道如何解决(见上文)。比较rapidjson文档错误 - 错误没有运算符[]匹配这些操作数
这是rapidjson:
static const std::string& JSON()
{
static const std::string j =
"{"
"\"SimpleCompany:Manager\":{"
"\"read\":\"true\""
"\"update\":\"true\""
"\"delete\":\"true\""
"\"insert\":\"false\""
"},"
"\"SimpleCompany:Manager\":{"
"\"read\":\"true\""
"\"update\":\"true\""
"\"delete\":\"false\""
"\"insert\":\"false\""
"},"
"}";
return j;
}
这是我尝试两个文件可能与相同内容的比较:
rapidjson::StringStream strStream(JSON().c_str());
rapidjson::Document origDocument;
origDocument.ParseStream(strStream); //newDocument obtained other way
ASSERT_TRUE(newDocument["read"] == origDocument["read"]); //error no operator [] matches these operands
ASSERT_TRUE(strcmp(newDocument["read"] , origDocument["read"])); //error no operator [] matches these operands
const rapidjson::Value& a1 = newDocument["read"]; //error no operator [] matches these operands
不知道如何正确地比较它们的值?我尝试了两种方法,但他们不喜欢[。
米洛说,有一个equality operator。看起来我比较了诸如rapidjson tutorial之类的东西,虽然他们将密钥与预期值进行比较,并且我将两个文档的密钥进行比较以获得相等性,这对我来说似乎没有问题。