Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
simplewriter.cpp
Go to the documentation of this file.
1
#include "
rapidjson/writer.h
"
2
#include "
rapidjson/stringbuffer.h
"
3
#include <iostream>
4
5
using namespace
rapidjson
;
6
using namespace
std
;
7
8
int
main
() {
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
}
GenericStringBuffer::GetString
const Ch * GetString() const
Definition
stringbuffer.h:73
Writer
JSON writer.
Definition
writer.h:89
Writer::EndObject
bool EndObject(SizeType memberCount=0)
Definition
writer.h:230
Writer::Key
bool Key(const Ch *str, SizeType length, bool copy=false)
Definition
writer.h:221
Writer::Double
bool Double(double d)
Writes the given double value to the stream.
Definition
writer.h:193
Writer::StartArray
bool StartArray()
Definition
writer.h:239
Writer::Uint
bool Uint(unsigned u)
Definition
writer.h:184
Writer::String
bool String(const Ch *str, SizeType length, bool copy=false)
Definition
writer.h:202
Writer::EndArray
bool EndArray(SizeType elementCount=0)
Definition
writer.h:245
Writer::Bool
bool Bool(bool b)
Definition
writer.h:182
Writer::StartObject
bool StartObject()
Definition
writer.h:215
Writer::Null
bool Null()
Definition
writer.h:181
StringBuffer
GenericStringBuffer< UTF8< char >, CrtAllocator > StringBuffer
Definition
fwd.h:61
rapidjson
main RapidJSON namespace
std
STL namespace.
main
int main()
Definition
simplewriter.cpp:8
stringbuffer.h
writer.h
external
rapidjson
example
simplewriter
simplewriter.cpp
Generated on
for Electroneum by
1.17.0