]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rapidjson/example/simpledom/simpledom.cpp
2 // This example does not handle errors.
4 #include "rapidjson/document.h"
5 #include "rapidjson/writer.h"
6 #include "rapidjson/stringbuffer.h"
9 using namespace rapidjson
;
12 // 1. Parse a JSON string into DOM.
13 const char* json
= "{\"project\":\"rapidjson\",\"stars\":10}";
17 // 2. Modify it by DOM.
18 Value
& s
= d
["stars"];
19 s
.SetInt(s
.GetInt() + 1);
21 // 3. Stringify the DOM
23 Writer
<StringBuffer
> writer(buffer
);
26 // Output {"project":"rapidjson","stars":11}
27 std::cout
<< buffer
.GetString() << std::endl
;