diff options
author | Philippe Coval <philippe.coval@osg.samsung.com> | 2017-02-24 21:48:50 +0100 |
---|---|---|
committer | Philippe Coval <philippe.coval@osg.samsung.com> | 2017-06-07 13:50:44 +0200 |
commit | 909c7a2a6012c599da5e5b3bc43d6d8ad8f024d7 (patch) | |
tree | dfea145ba1b4f26e3bf04fadd716082c857ab83c /extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp | |
parent | 937dc35e2ea1c92c30a4250d42408681d7f06e02 (diff) | |
download | iotivity-sandbox/pcoval/on/latest/tizen.tar.gz iotivity-sandbox/pcoval/on/latest/tizen.tar.bz2 iotivity-sandbox/pcoval/on/latest/tizen.zip |
rapidjson: Import 1.0.2sandbox/pcoval/on/latest/tizen
Change-Id: Ia3ba542040218839fd5625e4a4f1ea73de3d1856
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Diffstat (limited to 'extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp')
-rw-r--r-- | extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp b/extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp new file mode 100644 index 000000000..80384199a --- /dev/null +++ b/extlibs/rapidjson/rapidjson/example/simpledom/simpledom.cpp @@ -0,0 +1,29 @@ +// JSON simple example +// This example does not handle errors. + +#include "rapidjson/document.h" +#include "rapidjson/writer.h" +#include "rapidjson/stringbuffer.h" +#include <iostream> + +using namespace rapidjson; + +int main() { + // 1. Parse a JSON string into DOM. + const char* json = "{\"project\":\"rapidjson\",\"stars\":10}"; + Document d; + d.Parse(json); + + // 2. Modify it by DOM. + Value& s = d["stars"]; + s.SetInt(s.GetInt() + 1); + + // 3. Stringify the DOM + StringBuffer buffer; + Writer<StringBuffer> writer(buffer); + d.Accept(writer); + + // Output {"project":"rapidjson","stars":11} + std::cout << buffer.GetString() << std::endl; + return 0; +} |