I am the author of rapidjson. Thank you for your question. I wrote this down for publication at http://code.google.com/p/rapidjson/issues/detail?id=45
This is because GenericValue :: Accept () is not a constant.
As GenericValue :: Accept () only generates events for the handler, it does not need to change the value and its decents. Therefore, it should change:
template <typename Handler> GenericValue& Accept(Handler& handler)
to
template <typename Handler> const GenericValue& Accept(Handler& handler) const
You can fix this on your quickjson / document.h or download the latest version (trunk or branch 0.1x).
After this change, you can stringfy the value of const as in the tutorial:
const Value& v = ...; FileStream f(stdout); PrettyWriter<FileStream> writer(f); v.Accept(writer);
Or to the string buffer:
const Value& v = ...; StringBuffer buffer; PrettyWriter<StringBuffer> writer(buffer); v.Accept(writer); const char* json = buffer.GetString();
source share