문제

I try setting a Value to string, using SetString, but when I try to get it, via GetString(), some random output shows up. Code:

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

What am I doing wrong?

도움이 되었습니까?

해결책

OK, after browsing trough the source code, documentation and mostly every mention of rapidjson over the internet, I found something interesting:

There are a couple of functions SetString, and this is the one you have to use:

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

After that, you can call GetString()on the Valueand it returns the original string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top