Clear the JsonObject or JsonArray in deserializeJson()

This commit is contained in:
Benoit Blanchon
2018-03-18 14:50:52 +01:00
parent cf149940ed
commit 0d1623edef
15 changed files with 126 additions and 9 deletions

View File

@ -66,4 +66,15 @@ TEST_CASE("deserializeJson(StaticJsonObject&)") {
REQUIRE(err != JsonError::Ok);
}
SECTION("Should clear the JsonObject") {
StaticJsonObject<JSON_OBJECT_SIZE(1)> obj;
char input[] = "{\"hello\":\"world\"}";
deserializeJson(obj, input);
deserializeJson(obj, "{}");
REQUIRE(obj.size() == 0);
REQUIRE(obj.memoryUsage() == JSON_OBJECT_SIZE(0));
}
}