diff options
Diffstat (limited to '3rdparty/rapidjson/example/simplewriter/simplewriter.cpp')
-rw-r--r-- | 3rdparty/rapidjson/example/simplewriter/simplewriter.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/3rdparty/rapidjson/example/simplewriter/simplewriter.cpp b/3rdparty/rapidjson/example/simplewriter/simplewriter.cpp index f8891504bc8..8d1275c2923 100644 --- a/3rdparty/rapidjson/example/simplewriter/simplewriter.cpp +++ b/3rdparty/rapidjson/example/simplewriter/simplewriter.cpp @@ -9,26 +9,27 @@ int main() { StringBuffer s; Writer<StringBuffer> writer(s); - writer.StartObject(); - writer.String("hello"); - writer.String("world"); - writer.String("t"); + writer.StartObject(); // Between StartObject()/EndObject(), + writer.Key("hello"); // output a key, + writer.String("world"); // follow by a value. + writer.Key("t"); writer.Bool(true); - writer.String("f"); + writer.Key("f"); writer.Bool(false); - writer.String("n"); + writer.Key("n"); writer.Null(); - writer.String("i"); + writer.Key("i"); writer.Uint(123); - writer.String("pi"); + writer.Key("pi"); writer.Double(3.1416); - writer.String("a"); - writer.StartArray(); + writer.Key("a"); + writer.StartArray(); // Between StartArray()/EndArray(), for (unsigned i = 0; i < 4; i++) - writer.Uint(i); + writer.Uint(i); // all values are elements of the array. writer.EndArray(); writer.EndObject(); + // {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1,2,3]} cout << s.GetString() << endl; return 0; |