MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / serialization_example3

Function serialization_example3

examples_boost/serialization_examples.cpp:96–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void serialization_example3()
97{
98 {
99 json val = json::parse(R"(
100 [
101 {"first-name" : "John",
102 "last-name" : "Doe"},
103 {"first-name" : "Jane",
104 "last-name" : "Doe"}
105 ]
106 )");
107
108 auto options = json_options{}
109 .array_object_line_splits(line_split_kind::same_line);
110 std::cout << "array_object_line_splits(line_split_kind::same_line)" << std::endl;
111 std::cout << pretty_print(val,options) << std::endl;
112 }
113
114 {
115 json val = json::parse(R"({
116 "verts" : [1, 2, 3],
117
118 "normals" : [1, 0, 1],
119
120 "uvs" : [ 0, 0, 1, 1 ]
121 }
122 )");
123 std::cout << "Default print" << std::endl;
124 std::cout << print(val) << std::endl;
125
126 std::cout << "Default pretty print" << std::endl;
127 std::cout << pretty_print(val) << std::endl;
128
129 auto options1 = json_options{}
130 .array_array_line_splits(line_split_kind::same_line);
131 std::cout << pretty_print(val,options1) << std::endl;
132
133 auto options = json_options{}
134 .object_object_line_splits(line_split_kind::new_line);;
135 std::cout << pretty_print(val,options) << std::endl;
136 }
137
138 {
139 json val2 = json::parse(R"(
140 {
141 "data":
142 {
143 "item": [[2],[4,5,2,3],[4],[4,5,2,3],[2],[4,5,3],[2],[4,3]], //A two-dimensional array
144 //blank line
145 "id": [0,1,2,3,4,5,6,7] //A one-dimensional array
146 }
147 }
148 )");
149
150 std::cout << "Default" << std::endl;
151 std::cout << pretty_print(val2) << std::endl;
152
153 std::cout << "array_array_line_splits(line_split_kind::new_line)" << std::endl;

Callers 1

mainFunction · 0.85

Calls 6

parseFunction · 0.85
pretty_printFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected