2

我尝试使用 将值设置为字符串,SetString但是当我尝试通过 获取它时,会GetString()显示一些随机输出。代码:

someDoc[someObjKey].AddMember(someStringKey.c_str(), someStringValueAFunctionReturns.c_str(), someDoc.GetAllocator());
std::cout << someDoc[someObjKey][someStringKey.c_str()].GetString();

我究竟做错了什么?

4

1 回答 1

7

好的,在浏览了源代码、文档以及互联网上几乎每一次提到 rapidjson 之后,我发现了一些有趣的东西:

有几个功能SetString,这是您必须使用的功能:

GenericValue& SetString(const Ch* s, Allocator& allocator)

之后,您可以调用GetString()Value,它会返回原始字符串。

于 2013-12-07T19:23:38.813 回答