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:
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user