Removed JsonArray::is<T>(i) and JsonArray::set(i,v)

Removed `JsonObject::is<T>(k)` and `JsonObject::set(k,v)`
Replaced `T JsonArray::get<T>(i)` with `JsonVariant JsonArray::get(i)`
Replaced `T JsonObject::get<T>(k)` with `JsonVariant JsonObject::get(k)`
This commit is contained in:
Benoit Blanchon
2018-10-18 14:51:02 +02:00
parent 4eee8e8bdf
commit 1a4515c0b9
20 changed files with 38 additions and 615 deletions

View File

@ -31,70 +31,6 @@ TEST_CASE("std::string") {
REQUIRE(std::string("value") == obj[std::string("key")]);
}
SECTION("set(key)") {
JsonObject obj = doc.to<JsonObject>();
std::string key("hello");
obj.set(key, "world");
eraseString(key);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("set(value)") {
JsonObject obj = doc.to<JsonObject>();
std::string value("world");
obj.set("hello", value);
eraseString(value);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("set(key,value)") {
JsonObject obj = doc.to<JsonObject>();
std::string key("hello");
std::string value("world");
obj.set(key, value);
eraseString(key);
eraseString(value);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("set(JsonArraySubscript)") {
JsonObject obj = doc.to<JsonObject>();
DynamicJsonDocument doc2;
JsonArray arr = doc2.to<JsonArray>();
arr.add("world");
obj.set(std::string("hello"), arr[0]);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("set(JsonObjectSubscript)") {
JsonObject obj = doc.to<JsonObject>();
DynamicJsonDocument doc2;
JsonObject obj2 = doc2.to<JsonObject>();
obj2.set("x", "world");
obj.set(std::string("hello"), obj2["x"]);
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("get<T>()") {
char json[] = "{\"key\":\"value\"}";
deserializeJson(doc, json);
JsonObject obj = doc.as<JsonObject>();
REQUIRE(std::string("value") == obj.get<const char *>(std::string("key")));
}
SECTION("is<T>()") {
char json[] = "{\"key\":\"value\"}";
deserializeJson(doc, json);
JsonObject obj = doc.as<JsonObject>();
REQUIRE(true == obj.is<const char *>(std::string("key")));
}
SECTION("createNestedObject()") {
JsonObject obj = doc.to<JsonObject>();
std::string key = "key";