1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

BSON: support objects with null members

This commit is contained in:
Julian Becker
2018-09-15 11:38:26 +02:00
parent 6c447de076
commit c5ef023171
4 changed files with 63 additions and 0 deletions

View File

@ -208,6 +208,29 @@ TEST_CASE("BSON")
CHECK(json::from_bson(result, true, false) == j);
}
SECTION("non-empty object with null member")
{
json j =
{
{ "entry", nullptr }
};
std::vector<uint8_t> expected =
{
0x0C, 0x00, 0x00, 0x00, // size (little endian)
0x0A, /// entry: null
'e', 'n', 't', 'r', 'y', '\x00',
0x00 // end marker
};
const auto result = json::to_bson(j);
CHECK(result == expected);
// roundtrip
CHECK(json::from_bson(result) == j);
CHECK(json::from_bson(result, true, false) == j);
}
}
}