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

Function oid_example

examples/src/bson_examples.cpp:303–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303void 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
324int main()
325{

Callers 1

mainFunction · 0.85

Calls 3

encode_bsonFunction · 0.85
atMethod · 0.80
tagMethod · 0.45

Tested by

no test coverage detected