| 181 | } |
| 182 | |
| 183 | void serialization_example4() |
| 184 | { |
| 185 | json val; |
| 186 | val["data"]["id"] = json(json_array_arg, {0,1,2,3,4,5,6,7}); |
| 187 | val["data"]["item"] = json(json_array_arg, {json(json_array_arg, {2}), |
| 188 | json(json_array_arg, {4,5,2,3}), |
| 189 | json(json_array_arg, {4}), |
| 190 | json(json_array_arg, {4,5,2,3}), |
| 191 | json(json_array_arg, {2}), |
| 192 | json(json_array_arg, {4,5,3}), |
| 193 | json(json_array_arg, {2}), |
| 194 | json(json_array_arg, {4,3})}); |
| 195 | |
| 196 | std::cout << "Default array-array split line options" << std::endl; |
| 197 | std::cout << pretty_print(val) << std::endl; |
| 198 | |
| 199 | std::cout << "Array-array same line options" << std::endl; |
| 200 | auto options1 = json_options{} |
| 201 | .array_array_line_splits(line_split_kind::same_line); |
| 202 | std::cout << pretty_print(val, options1) << std::endl; |
| 203 | |
| 204 | std::cout << "object_array_line_splits(line_split_kind::new_line)" << std::endl; |
| 205 | std::cout << "array_array_line_splits(line_split_kind::same_line)" << std::endl; |
| 206 | auto options2 = json_options{} |
| 207 | .object_array_line_splits(line_split_kind::new_line) |
| 208 | .array_array_line_splits(line_split_kind::same_line); |
| 209 | std::cout << pretty_print(val, options2 ) << std::endl; |
| 210 | |
| 211 | std::cout << "object_array_line_splits(line_split_kind::new_line)" << std::endl; |
| 212 | std::cout << "array_array_line_splits(line_split_kind::multi_line)" << std::endl; |
| 213 | auto options3 = json_options{} |
| 214 | .object_array_line_splits(line_split_kind::new_line) |
| 215 | .array_array_line_splits(line_split_kind::multi_line); |
| 216 | std::cout << pretty_print(val, options3) << std::endl; |
| 217 | |
| 218 | { |
| 219 | json val = json::parse(R"( |
| 220 | { |
| 221 | "header" : {"properties": {}}, |
| 222 | "data": |
| 223 | { |
| 224 | "tags" : [], |
| 225 | "id" : [1,2,3], |
| 226 | "item": [[1,2,3]] |
| 227 | } |
| 228 | } |
| 229 | )"); |
| 230 | std::cout << "Default" << std::endl; |
| 231 | std::cout << pretty_print(val) << std::endl; |
| 232 | |
| 233 | std::string style1 = "array_array_line_splits(line_split_kind:same_line)"; |
| 234 | std::cout << style1 << std::endl; |
| 235 | auto options1 = json_options{} |
| 236 | .array_array_line_splits(line_split_kind::same_line); |
| 237 | std::cout << pretty_print(val,options1) << std::endl; |
| 238 | |
| 239 | std::string style2 = "array_array_line_splits(line_split_kind::new_line)"; |
| 240 | std::cout << style2 << std::endl; |
no test coverage detected