Electroneum
simplewriter.cpp File Reference
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>
Include dependency graph for simplewriter.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 8 of file simplewriter.cpp.

8  {
9  StringBuffer s;
10  Writer<StringBuffer> writer(s);
11 
12  writer.StartObject(); // Between StartObject()/EndObject(),
13  writer.Key("hello"); // output a key,
14  writer.String("world"); // follow by a value.
15  writer.Key("t");
16  writer.Bool(true);
17  writer.Key("f");
18  writer.Bool(false);
19  writer.Key("n");
20  writer.Null();
21  writer.Key("i");
22  writer.Uint(123);
23  writer.Key("pi");
24  writer.Double(3.1416);
25  writer.Key("a");
26  writer.StartArray(); // Between StartArray()/EndArray(),
27  for (unsigned i = 0; i < 4; i++)
28  writer.Uint(i); // all values are elements of the array.
29  writer.EndArray();
30  writer.EndObject();
31 
32  // {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1,2,3]}
33  cout << s.GetString() << endl;
34 
35  return 0;
36 }
JSON writer.
Definition: fwd.h:95
const Ch * GetString() const
Definition: stringbuffer.h:73
Here is the call graph for this function: