Following rapidjson documentation I'm able to generate a pretty-printed JSON ouput writting in a key-by-key approach, e.g.:
rapidjson::StringBuffer s;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
writer.StartObject();
writer.Key("hello");
writer.String("world");
writer.EndObject();
std::string result = s.GetString();
However, I would like to do the same but using a JSON string (i.e. a std::string
object which content is a valid JSON) to feed the writer, instead of calling Key()
, String()
and so.
Looking to the PrettyWriter
API I don't see any method to pass a JSON string in that way. An alternative would be to pass the parsed JSON string as a rapidjson::Document
object, but I haven't found that possibility.
Any idea about how this could be done, please?