26 printTitle(
"Sample use serialize of JsonMessageCover");
28 const std::string
data =
"Hello world!";
30 unsigned int ttl = 234;
35 jsonMessageCover.
setTTL(ttl);
38 std::cout <<
"serialize => " << std::boolalpha << jsonMessageCover.
serialize(json) <<
std::endl;
39 std::cout <<
"isError => " << std::boolalpha << jsonMessageCover.
isError() <<
std::endl;
43 std::cout <<
"JSON: " << json <<
std::endl;
48 printTitle(
"Sample use unserialize of JsonMessageCover");
52 #if JSON_USE_BASE64 == 1
53 std::cout <<
"JSON_USE_BASE64 == 1" <<
std::endl;
54 json =
"{\"data\":\"SGVsbG8gd29ybGQh\",\"ttl\":234,\"type\":1}";
56 std::cout <<
"JSON_USE_BASE64 != 1" <<
std::endl;
57 json =
"{\"data\":\"Hello world!\",\"ttl\":234,\"type\":1}";
61 std::cout <<
"unserialize => " << std::boolalpha << jsonMessageCover.
unserialize(json) <<
std::endl;
62 std::cout <<
"isError => " << std::boolalpha << jsonMessageCover.
isError() <<
std::endl;
66 std::cout <<
"Type: " <<
static_cast<unsigned int>(jsonMessageCover.
getType()) << std::endl;
73 printTitle(
"Sample use output stream for JsonMessageCover");
75 const std::string
data =
"Hello world!";
77 unsigned int ttl = 234;
82 jsonMessageCover.
setTTL(ttl);
84 std::stringstream json;
85 json << jsonMessageCover;
87 std::cout <<
"isError => " << std::boolalpha << jsonMessageCover.
isError() <<
std::endl;
88 if (jsonMessageCover.isError())
89 std::cout <<
"ErrorCode: " << jsonMessageCover.getErrorCode() <<
"\tErrorMsg: " << jsonMessageCover.getErrorMsg() <<
std::endl;
91 std::cout <<
"JSON: " << json.str() <<
std::endl;
96 printTitle(
"Sample use input stream for JsonMessageCover");
98 std::stringstream json;
100 #if JSON_USE_BASE64 == 1
101 std::cout <<
"JSON_USE_BASE64 == 1" <<
std::endl;
102 json <<
"{\"data\":\"SGVsbG8gd29ybGQh\",\"ttl\":234,\"type\":1}";
104 std::cout <<
"JSON_USE_BASE64 != 1" <<
std::endl;
105 json <<
"{\"data\":\"Hello world!\",\"ttl\":234,\"type\":1}";
109 json >> jsonMessageCover;
111 std::cout <<
"isError => " << std::boolalpha << jsonMessageCover.
isError() <<
std::endl;
112 if (jsonMessageCover.isError())
113 std::cout <<
"ErrorCode: " << jsonMessageCover.getErrorCode() <<
"\tErrorMsg: " << jsonMessageCover.getErrorMsg() <<
std::endl;
115 std::cout <<
"Type: " <<
static_cast<unsigned int>(jsonMessageCover.getType()) << std::endl;
116 std::cout <<
"Data: " << jsonMessageCover.getData() <<
std::endl;
117 std::cout <<
"TTL: " << jsonMessageCover.getTTL() <<
std::endl;
122 printTitle(
"Sample error message for JsonMessageCover");
124 std::stringstream json;
126 #if JSON_USE_BASE64 == 1
127 std::cout <<
"JSON_USE_BASE64 == 1" <<
std::endl;
128 json <<
"{\"data\":\"SGVsbG8gd29ybGQh\",\"ttl\":234,\"typ";
130 std::cout <<
"JSON_USE_BASE64 != 1" <<
std::endl;
131 json <<
"{\"data\":\"Hello world!\",\"ttl\":234,\"typ";
135 json >> jsonMessageCover;
137 std::cout <<
"isError => " << std::boolalpha << jsonMessageCover.
isError() <<
std::endl;
138 if (jsonMessageCover.isError())
139 std::cout <<
"ErrorCode: " << jsonMessageCover.getErrorCode() <<
"\tErrorMsg: " << jsonMessageCover.getErrorMsg() <<
std::endl;