aboutsummaryrefslogtreecommitdiff
path: root/example/streamWrite/streamWrite.cpp
diff options
context:
space:
mode:
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;
+}