Fix filter not working in zero-copy mode (fixes #1697)

This commit is contained in:
Benoit Blanchon
2022-01-13 16:12:56 +01:00
parent 4f6244eef4
commit 21b2c76524
5 changed files with 46 additions and 1 deletions

View File

@ -279,6 +279,22 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc["a"] == 2);
}
SECTION("Repeated key with zero copy mode") { // issue #1697
char input[] = "{a:{b:{c:1}},a:2}";
DeserializationError err = deserializeJson(doc, input);
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc["a"] == 2);
}
SECTION("NUL in keys") { // we don't support NULs in keys
DeserializationError err =
deserializeJson(doc, "{\"x\\u0000a\":1,\"x\\u0000b\":2}");
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc.as<std::string>() == "{\"x\":2}");
}
}
SECTION("Should clear the JsonObject") {