1 #include "rapidjson/writer.h" 2 #include "rapidjson/stringbuffer.h" 3 #include <iostream> 4 5 using namespace rapidjson; 6 using namespace std; 7 main()8int main() { 9 StringBuffer s; 10 Writer<StringBuffer> writer(s); 11 12 writer.StartObject(); 13 writer.String("hello"); 14 writer.String("world"); 15 writer.String("t"); 16 writer.Bool(true); 17 writer.String("f"); 18 writer.Bool(false); 19 writer.String("n"); 20 writer.Null(); 21 writer.String("i"); 22 writer.Uint(123); 23 writer.String("pi"); 24 writer.Double(3.1416); 25 writer.String("a"); 26 writer.StartArray(); 27 for (unsigned i = 0; i < 4; i++) 28 writer.Uint(i); 29 writer.EndArray(); 30 writer.EndObject(); 31 32 cout << s.GetString() << endl; 33 34 return 0; 35 } 36