aboutsummaryrefslogtreecommitdiff
path: root/example/streamWrite/streamWrite.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 15:04:01 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 15:04:01 +0000
commit35369820b978918022eed0f09d615d20c8cd3fa8 (patch)
treea39bc599e78f83beddd0e70400ba7806c2d1739a /example/streamWrite/streamWrite.cpp
parent3c3f2712111366454e21b0f4c3f9e5b312908591 (diff)
parent16bffac93e8a9e030713a0d5d721de12aebdcbad (diff)
downloadjsoncpp-35369820b978918022eed0f09d615d20c8cd3fa8.tar.gz
Change-Id: I9b5c3c772ca79700fae95380e2e44f7619e70972
Diffstat (limited to 'example/streamWrite/streamWrite.cpp')
-rw-r--r--example/streamWrite/streamWrite.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/example/streamWrite/streamWrite.cpp b/example/streamWrite/streamWrite.cpp
new file mode 100644
index 0000000..6f7f797
--- /dev/null
+++ b/example/streamWrite/streamWrite.cpp
@@ -0,0 +1,22 @@
+#include "json/json.h"
+#include <iostream>
+/** \brief Write the Value object to a stream.
+ * Example Usage:
+ * $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite
+ * $./streamWrite
+ * {
+ * "Age" : 20,
+ * "Name" : "robin"
+ * }
+ */
+int main() {
+ Json::Value root;
+ Json::StreamWriterBuilder builder;
+ const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
+
+ root["Name"] = "robin";
+ root["Age"] = 20;
+ writer->write(root, &std::cout);
+
+ return EXIT_SUCCESS;
+}