| 301 | } |
| 302 | |
| 303 | void oid_example() |
| 304 | { |
| 305 | std::vector<uint8_t> input = { |
| 306 | 0x16,0x00,0x00,0x00, // Document has 22 bytes |
| 307 | 0x07, // ObjectId |
| 308 | 0x6F,0x69,0x64,0x00, // "oid" |
| 309 | 0x12,0x34,0x56,0x78,0x90,0xAB, |
| 310 | 0xCD,0xEF,0x12,0x34,0xAB,0xCD, // (byte*12) |
| 311 | 0x00 // terminating null |
| 312 | }; |
| 313 | |
| 314 | json j = bson::decode_bson<json>(input); |
| 315 | |
| 316 | std::cout << "(1) " << j << "\n\n"; |
| 317 | std::cout << "(2) " << j.at("oid").tag() << "\n\n"; |
| 318 | |
| 319 | std::vector<uint8_t> output; |
| 320 | bson::encode_bson(j, output); |
| 321 | assert(output == input); |
| 322 | } |
| 323 | |
| 324 | int main() |
| 325 | { |
no test coverage detected