simplewriter.cpp (rapidjson-1.0.2) | : | simplewriter.cpp (rapidjson-1.1.0) | ||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
#include "rapidjson/stringbuffer.h" | #include "rapidjson/stringbuffer.h" | |||
#include <iostream> | #include <iostream> | |||
using namespace rapidjson; | using namespace rapidjson; | |||
using namespace std; | using namespace std; | |||
int main() { | int main() { | |||
StringBuffer s; | StringBuffer s; | |||
Writer<StringBuffer> writer(s); | Writer<StringBuffer> writer(s); | |||
writer.StartObject(); | writer.StartObject(); // Between StartObject()/EndObject(), | |||
writer.String("hello"); | writer.Key("hello"); // output a key, | |||
writer.String("world"); | writer.String("world"); // follow by a value. | |||
writer.String("t"); | writer.Key("t"); | |||
writer.Bool(true); | writer.Bool(true); | |||
writer.String("f"); | writer.Key("f"); | |||
writer.Bool(false); | writer.Bool(false); | |||
writer.String("n"); | writer.Key("n"); | |||
writer.Null(); | writer.Null(); | |||
writer.String("i"); | writer.Key("i"); | |||
writer.Uint(123); | writer.Uint(123); | |||
writer.String("pi"); | writer.Key("pi"); | |||
writer.Double(3.1416); | writer.Double(3.1416); | |||
writer.String("a"); | writer.Key("a"); | |||
writer.StartArray(); | writer.StartArray(); // Between StartArray()/EndArray(), | |||
for (unsigned i = 0; i < 4; i++) | for (unsigned i = 0; i < 4; i++) | |||
writer.Uint(i); | writer.Uint(i); // all values are elements of the array. | |||
writer.EndArray(); | writer.EndArray(); | |||
writer.EndObject(); | writer.EndObject(); | |||
// {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1 ,2,3]} | ||||
cout << s.GetString() << endl; | cout << s.GetString() << endl; | |||
return 0; | return 0; | |||
} | } | |||
End of changes. 8 change blocks. | ||||
11 lines changed or deleted | 12 lines changed or added |