Serialize empty tuple into '[]' instead of null (#4594)

Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>
This commit is contained in:
Michael Valladolid
2025-01-19 04:34:11 +09:00
committed by GitHub
parent e72046ef9f
commit bdb8d2b7b3
4 changed files with 35 additions and 0 deletions

View File

@@ -814,6 +814,15 @@ TEST_CASE("regression tests 2")
}
}
SECTION("issue #4530 - Serialization of empty tuple")
{
const auto source_tuple = std::tuple<>();
const nlohmann::json j = source_tuple;
CHECK(j.get<decltype(source_tuple)>() == source_tuple);
CHECK("[]" == j.dump());
}
SECTION("issue #2865 - ASAN detects memory leaks")
{
// the code below is expected to not leak memory