Reputation: 6573
I am trying to use rapidjson to output itself to a string to save to a database, using the following code :
StringBuffer buffer;
Writer<FileStream> writer(buffer);
rest.Accept(writer);
string reststring = buffer.GetString();
where rest is a rapidjson::Document.
However I get the following error :
no matching function for call to ‘rapidjson::Writer<rapidjson::FileStream>::Writer (rapidjson::StringBuffer&)’.
which is strange because the author of rapidjson recommended this method in an answer to a previous SO question.
Upvotes: 2
Views: 7144
Reputation: 2097
Try to use rapidjson::StringBuffer
and rapidjson::Writer
for get string output.
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
rest.Accept(writer);
std::string str = buffer.GetString();
Here you can get value in both string
as well as std::string
.
Above I used std::string
for get value.
This works...
Upvotes: 4
Reputation: 6573
I must have been tired at 9 last night when I wrote this piece of code.
Changing
Writer<FileStream> writer(buffer);
to
Writer<StringBuffer> writer(buffer);
solves the problem.
Upvotes: 6
Reputation: 21510
As your compiler suggest, you have to modify your code in:
StringBuffer buffer;
Writer<FileStream> writer(&buffer);
Or:
StringBuffer* buffer;
Writer<FileStream> writer(buffer);
Upvotes: 0