• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "json/json.h"
2 #include <iostream>
3 /** \brief Write the Value object to a stream.
4  * Example Usage:
5  * $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite
6  * $./streamWrite
7  * {
8  *     "Age" : 20,
9  *     "Name" : "robin"
10  * }
11  */
main()12 int main() {
13   Json::Value root;
14   Json::StreamWriterBuilder builder;
15   const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
16 
17   root["Name"] = "robin";
18   root["Age"] = 20;
19   writer->write(root, &std::cout);
20 
21   return EXIT_SUCCESS;
22 }
23