1 #include "rapidjson/writer.h"
2 #include "rapidjson/stringbuffer.h"
5 using namespace rapidjson;
10 Writer<StringBuffer> writer(s);
12 writer.StartObject(); // Between StartObject()/EndObject(),
13 writer.Key("hello"); // output a key,
14 writer.String("world"); // follow by a value.
24 writer.Double(3.1416);
26 writer.StartArray(); // Between StartArray()/EndArray(),
27 for (unsigned i = 0; i < 4; i++)
28 writer.Uint(i); // all values are elements of the array.
32 // {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1,2,3]}
33 cout << s.GetString() << endl;