mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 11:36:36 +02:00
Remove createNestedArray()
and createNestedObject()
This commit is contained in:
@ -28,3 +28,4 @@ HEAD
|
||||
* Call `shrinkToFit()` in `deserializeJson()` and `deserializeMsgPack()`
|
||||
* `serializeJson()` and `serializeMsgPack()` replace the content of `std::string` and `String` instead of appending to it
|
||||
* Replace `add()` with `add<T>()` (`add(T)` is still supported)
|
||||
* Remove `createNestedArray()` and `createNestedObject()` (use `to<JsonArray>()` and `to<JsonObject>()` instead)
|
||||
|
@ -22,7 +22,7 @@ void setup() {
|
||||
doc["time"] = 1351824120;
|
||||
|
||||
// Add an array.
|
||||
JsonArray data = doc.createNestedArray("data");
|
||||
JsonArray data = doc["data"].to<JsonArray>();
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void loop() {
|
||||
JsonDocument doc;
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray analogValues = doc.createNestedArray("analog");
|
||||
JsonArray analogValues = doc["analog"].to<JsonArray>();
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
@ -70,7 +70,7 @@ void loop() {
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray digitalValues = doc.createNestedArray("digital");
|
||||
JsonArray digitalValues = doc["digital"].to<JsonArray>();
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
@ -50,7 +50,7 @@ void loop() {
|
||||
JsonDocument doc;
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray analogValues = doc.createNestedArray("analog");
|
||||
JsonArray analogValues = doc["analog"].to<JsonArray>();
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
@ -60,7 +60,7 @@ void loop() {
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray digitalValues = doc.createNestedArray("digital");
|
||||
JsonArray digitalValues = doc["digital"].to<JsonArray>();
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
@ -22,7 +22,7 @@ int main() {
|
||||
|
||||
// Add an array.
|
||||
//
|
||||
JsonArray data = doc.createNestedArray("data");
|
||||
JsonArray data = doc["data"].to<JsonArray>();
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
|
@ -7,7 +7,6 @@ add_executable(JsonArrayTests
|
||||
clear.cpp
|
||||
compare.cpp
|
||||
copyArray.cpp
|
||||
createNested.cpp
|
||||
equals.cpp
|
||||
isNull.cpp
|
||||
iterator.cpp
|
||||
|
@ -43,15 +43,15 @@ TEST_CASE("Compare JsonArray with JsonArray") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
|
||||
CHECK(array1 == array2);
|
||||
CHECK(array1 <= array2);
|
||||
@ -62,15 +62,15 @@ TEST_CASE("Compare JsonArray with JsonArray") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello1");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello2");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
|
||||
CHECK(array1 != array2);
|
||||
CHECK_FALSE(array1 == array2);
|
||||
@ -107,15 +107,15 @@ TEST_CASE("Compare JsonArray with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array = doc.createNestedArray();
|
||||
JsonArray array = doc.add<JsonArray>();
|
||||
array.add(1);
|
||||
array.add("hello");
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
JsonVariant variant = doc.createNestedArray();
|
||||
JsonVariant variant = doc.add<JsonArray>();
|
||||
variant.add(1);
|
||||
variant.add("hello");
|
||||
variant.createNestedObject();
|
||||
variant.add<JsonObject>();
|
||||
|
||||
CHECK(array == variant);
|
||||
CHECK(array <= variant);
|
||||
@ -133,15 +133,15 @@ TEST_CASE("Compare JsonArray with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array = doc.createNestedArray();
|
||||
JsonArray array = doc.add<JsonArray>();
|
||||
array.add(1);
|
||||
array.add("hello1");
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
JsonVariant variant = doc.createNestedArray();
|
||||
JsonVariant variant = doc.add<JsonArray>();
|
||||
variant.add(1);
|
||||
variant.add("hello2");
|
||||
variant.createNestedObject();
|
||||
variant.add<JsonObject>();
|
||||
|
||||
CHECK(array != variant);
|
||||
CHECK_FALSE(array == variant);
|
||||
@ -199,15 +199,15 @@ TEST_CASE("Compare JsonArray with JsonVariantConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array = doc.createNestedArray();
|
||||
JsonArray array = doc.add<JsonArray>();
|
||||
array.add(1);
|
||||
array.add("hello");
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonVariantConst variant = array2;
|
||||
|
||||
CHECK(array == variant);
|
||||
@ -226,15 +226,15 @@ TEST_CASE("Compare JsonArray with JsonVariantConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array = doc.createNestedArray();
|
||||
JsonArray array = doc.add<JsonArray>();
|
||||
array.add(1);
|
||||
array.add("hello1");
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello2");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonVariantConst variant = array2;
|
||||
|
||||
CHECK(array != variant);
|
||||
@ -292,15 +292,15 @@ TEST_CASE("Compare JsonArray with JsonArrayConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonArrayConst carray2 = array2;
|
||||
|
||||
CHECK(array1 == carray2);
|
||||
@ -319,15 +319,15 @@ TEST_CASE("Compare JsonArray with JsonArrayConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello1");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello2");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonArrayConst carray2 = array2;
|
||||
|
||||
CHECK(array1 != carray2);
|
||||
@ -387,16 +387,16 @@ TEST_CASE("Compare JsonArrayConst with JsonArrayConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
JsonArrayConst carray1 = array1;
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonArrayConst carray2 = array2;
|
||||
|
||||
CHECK(carray1 == carray2);
|
||||
@ -408,16 +408,16 @@ TEST_CASE("Compare JsonArrayConst with JsonArrayConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello1");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
JsonArrayConst carray1 = array1;
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello2");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonArrayConst carray2 = array2;
|
||||
|
||||
CHECK(carray1 != carray2);
|
||||
@ -455,16 +455,16 @@ TEST_CASE("Compare JsonArrayConst with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
JsonArrayConst carray1 = array1;
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonVariant variant2 = array2;
|
||||
|
||||
CHECK(carray1 == variant2);
|
||||
@ -483,16 +483,16 @@ TEST_CASE("Compare JsonArrayConst with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different array") {
|
||||
JsonArray array1 = doc.createNestedArray();
|
||||
JsonArray array1 = doc.add<JsonArray>();
|
||||
array1.add(1);
|
||||
array1.add("hello1");
|
||||
array1.createNestedObject();
|
||||
array1.add<JsonObject>();
|
||||
JsonArrayConst carray1 = array1;
|
||||
|
||||
JsonArray array2 = doc.createNestedArray();
|
||||
JsonArray array2 = doc.add<JsonArray>();
|
||||
array2.add(1);
|
||||
array2.add("hello2");
|
||||
array2.createNestedObject();
|
||||
array2.add<JsonObject>();
|
||||
JsonVariant variant2 = array2;
|
||||
|
||||
CHECK(carray1 != variant2);
|
||||
|
@ -1,21 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("JsonArray basics") {
|
||||
JsonDocument doc;
|
||||
JsonArray array = doc.to<JsonArray>();
|
||||
|
||||
SECTION("CreateNestedArray") {
|
||||
JsonArray arr = array.createNestedArray();
|
||||
REQUIRE(arr == array[0].as<JsonArray>());
|
||||
}
|
||||
|
||||
SECTION("CreateNestedObject") {
|
||||
JsonObject obj = array.createNestedObject();
|
||||
REQUIRE(obj == array[0].as<JsonObject>());
|
||||
}
|
||||
}
|
@ -24,12 +24,12 @@ TEST_CASE("JsonArray::nesting()") {
|
||||
}
|
||||
|
||||
SECTION("returns 2 with nested array") {
|
||||
arr.createNestedArray();
|
||||
arr.add<JsonArray>();
|
||||
REQUIRE(arr.nesting() == 2);
|
||||
}
|
||||
|
||||
SECTION("returns 2 with nested object") {
|
||||
arr.createNestedObject();
|
||||
arr.add<JsonObject>();
|
||||
REQUIRE(arr.nesting() == 2);
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,6 @@ TEST_CASE("Unbound JsonArray") {
|
||||
REQUIRE(0 == array.size());
|
||||
}
|
||||
|
||||
SECTION("CreateNestedArrayFails") {
|
||||
REQUIRE(array.createNestedArray().isNull());
|
||||
}
|
||||
|
||||
SECTION("CreateNestedObjectFails") {
|
||||
REQUIRE(array.createNestedObject().isNull());
|
||||
}
|
||||
|
||||
SECTION("PrintToWritesBrackets") {
|
||||
char buffer[32];
|
||||
serializeJson(array, buffer, sizeof(buffer));
|
||||
|
@ -9,7 +9,6 @@ add_executable(JsonDocumentTests
|
||||
compare.cpp
|
||||
constructor.cpp
|
||||
containsKey.cpp
|
||||
createNested.cpp
|
||||
ElementProxy.cpp
|
||||
isNull.cpp
|
||||
issue1120.cpp
|
||||
|
@ -281,38 +281,6 @@ TEST_CASE("MemberProxy cast to JsonVariant") {
|
||||
CHECK(doc.as<std::string>() == "{\"hello\":\"toto\"}");
|
||||
}
|
||||
|
||||
TEST_CASE("MemberProxy::createNestedArray()") {
|
||||
JsonDocument doc;
|
||||
JsonArray arr = doc["items"].createNestedArray();
|
||||
arr.add(42);
|
||||
|
||||
CHECK(doc["items"][0][0] == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("MemberProxy::createNestedArray(key)") {
|
||||
JsonDocument doc;
|
||||
JsonArray arr = doc["weather"].createNestedArray("temp");
|
||||
arr.add(42);
|
||||
|
||||
CHECK(doc["weather"]["temp"][0] == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("MemberProxy::createNestedObject()") {
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc["items"].createNestedObject();
|
||||
obj["value"] = 42;
|
||||
|
||||
CHECK(doc["items"][0]["value"] == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("MemberProxy::createNestedObject(key)") {
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc["status"].createNestedObject("weather");
|
||||
obj["temp"] = 42;
|
||||
|
||||
CHECK(doc["status"]["weather"]["temp"] == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("Deduplicate keys") {
|
||||
SpyingAllocator spy;
|
||||
JsonDocument doc(&spy);
|
||||
|
@ -1,66 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("JsonDocument::createNestedArray()") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("promotes to array") {
|
||||
doc.createNestedArray();
|
||||
|
||||
REQUIRE(doc.is<JsonArray>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonDocument::createNestedArray(key)") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("key is const char*") {
|
||||
SECTION("promotes to object") {
|
||||
doc.createNestedArray("hello");
|
||||
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("key is std::string") {
|
||||
SECTION("promotes to object") {
|
||||
doc.createNestedArray(std::string("hello"));
|
||||
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonDocument::createNestedObject()") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("promotes to array") {
|
||||
doc.createNestedObject();
|
||||
|
||||
REQUIRE(doc.is<JsonArray>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonDocument::createNestedObject(key)") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("key is const char*") {
|
||||
SECTION("promotes to object") {
|
||||
doc.createNestedObject("hello");
|
||||
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("key is std::string") {
|
||||
SECTION("promotes to object") {
|
||||
doc.createNestedObject(std::string("hello"));
|
||||
|
||||
REQUIRE(doc.is<JsonObject>());
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@ add_executable(JsonObjectTests
|
||||
compare.cpp
|
||||
containsKey.cpp
|
||||
copy.cpp
|
||||
createNestedArray.cpp
|
||||
createNestedObject.cpp
|
||||
equals.cpp
|
||||
invalid.cpp
|
||||
isNull.cpp
|
||||
|
@ -43,12 +43,12 @@ TEST_CASE("Compare JsonObject with JsonObject") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello";
|
||||
object1["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello";
|
||||
object2["c"][0] = false;
|
||||
@ -62,12 +62,12 @@ TEST_CASE("Compare JsonObject with JsonObject") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello1";
|
||||
object1["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello2";
|
||||
object2["c"][0] = false;
|
||||
@ -107,12 +107,12 @@ TEST_CASE("Compare JsonObject with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object = doc.createNestedObject();
|
||||
JsonObject object = doc.add<JsonObject>();
|
||||
object["a"] = 1;
|
||||
object["b"] = "hello";
|
||||
object["c"][0] = false;
|
||||
|
||||
JsonVariant variant = doc.createNestedObject();
|
||||
JsonVariant variant = doc.add<JsonObject>();
|
||||
variant["a"] = 1;
|
||||
variant["b"] = "hello";
|
||||
variant["c"][0] = false;
|
||||
@ -133,12 +133,12 @@ TEST_CASE("Compare JsonObject with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object = doc.createNestedObject();
|
||||
JsonObject object = doc.add<JsonObject>();
|
||||
object["a"] = 1;
|
||||
object["b"] = "hello1";
|
||||
object["c"][0] = false;
|
||||
|
||||
JsonVariant variant = doc.createNestedObject();
|
||||
JsonVariant variant = doc.add<JsonObject>();
|
||||
variant["a"] = 1;
|
||||
variant["b"] = "hello2";
|
||||
variant["c"][0] = false;
|
||||
@ -199,12 +199,12 @@ TEST_CASE("Compare JsonObject with JsonVariantConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object = doc.createNestedObject();
|
||||
JsonObject object = doc.add<JsonObject>();
|
||||
object["a"] = 1;
|
||||
object["b"] = "hello";
|
||||
object["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello";
|
||||
object2["c"][0] = false;
|
||||
@ -226,12 +226,12 @@ TEST_CASE("Compare JsonObject with JsonVariantConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object = doc.createNestedObject();
|
||||
JsonObject object = doc.add<JsonObject>();
|
||||
object["a"] = 1;
|
||||
object["b"] = "hello1";
|
||||
object["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello2";
|
||||
object2["c"][0] = false;
|
||||
@ -292,12 +292,12 @@ TEST_CASE("Compare JsonObject with JsonObjectConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello";
|
||||
object1["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello";
|
||||
object2["c"][0] = false;
|
||||
@ -319,12 +319,12 @@ TEST_CASE("Compare JsonObject with JsonObjectConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello1";
|
||||
object1["c"][0] = false;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello2";
|
||||
object2["c"][0] = false;
|
||||
@ -387,13 +387,13 @@ TEST_CASE("Compare JsonObjectConst with JsonObjectConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello";
|
||||
object1["c"][0] = false;
|
||||
JsonObjectConst carray1 = object1;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello";
|
||||
object2["c"][0] = false;
|
||||
@ -408,13 +408,13 @@ TEST_CASE("Compare JsonObjectConst with JsonObjectConst") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello1";
|
||||
object1["c"][0] = false;
|
||||
JsonObjectConst carray1 = object1;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello2";
|
||||
object2["c"][0] = false;
|
||||
@ -455,13 +455,13 @@ TEST_CASE("Compare JsonObjectConst with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with identical object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello";
|
||||
object1["c"][0] = false;
|
||||
JsonObjectConst carray1 = object1;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello";
|
||||
object2["c"][0] = false;
|
||||
@ -483,13 +483,13 @@ TEST_CASE("Compare JsonObjectConst with JsonVariant") {
|
||||
}
|
||||
|
||||
SECTION("Compare with different object") {
|
||||
JsonObject object1 = doc.createNestedObject();
|
||||
JsonObject object1 = doc.add<JsonObject>();
|
||||
object1["a"] = 1;
|
||||
object1["b"] = "hello1";
|
||||
object1["c"][0] = false;
|
||||
JsonObjectConst carray1 = object1;
|
||||
|
||||
JsonObject object2 = doc.createNestedObject();
|
||||
JsonObject object2 = doc.add<JsonObject>();
|
||||
object2["a"] = 1;
|
||||
object2["b"] = "hello2";
|
||||
object2["c"][0] = false;
|
||||
|
@ -1,27 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("JsonObject::createNestedArray()") {
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
|
||||
SECTION("key is a const char*") {
|
||||
JsonArray arr = obj.createNestedArray("hello");
|
||||
REQUIRE(arr.isNull() == false);
|
||||
}
|
||||
|
||||
#ifdef HAS_VARIABLE_LENGTH_ARRAY
|
||||
SECTION("key is a VLA") {
|
||||
size_t i = 16;
|
||||
char vla[i];
|
||||
strcpy(vla, "hello");
|
||||
|
||||
JsonArray arr = obj.createNestedArray(vla);
|
||||
REQUIRE(arr.isNull() == false);
|
||||
}
|
||||
#endif
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("JsonObject::createNestedObject()") {
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
|
||||
SECTION("key is a const char*") {
|
||||
obj.createNestedObject("hello");
|
||||
}
|
||||
|
||||
#ifdef HAS_VARIABLE_LENGTH_ARRAY
|
||||
SECTION("key is a VLA") {
|
||||
size_t i = 16;
|
||||
char vla[i];
|
||||
strcpy(vla, "hello");
|
||||
|
||||
obj.createNestedObject(vla);
|
||||
}
|
||||
#endif
|
||||
}
|
@ -19,14 +19,6 @@ TEST_CASE("JsonObject::invalid()") {
|
||||
REQUIRE(0 == obj.size());
|
||||
}
|
||||
|
||||
SECTION("CreateNestedArrayFails") {
|
||||
REQUIRE(obj.createNestedArray("hello").isNull());
|
||||
}
|
||||
|
||||
SECTION("CreateNestedObjectFails") {
|
||||
REQUIRE(obj.createNestedObject("world").isNull());
|
||||
}
|
||||
|
||||
SECTION("serialize to 'null'") {
|
||||
char buffer[32];
|
||||
serializeJson(obj, buffer, sizeof(buffer));
|
||||
|
@ -24,12 +24,12 @@ TEST_CASE("JsonObject::nesting()") {
|
||||
}
|
||||
|
||||
SECTION("returns 2 with nested array") {
|
||||
obj.createNestedArray("nested");
|
||||
obj["nested"].to<JsonArray>();
|
||||
REQUIRE(obj.nesting() == 2);
|
||||
}
|
||||
|
||||
SECTION("returns 2 with nested object") {
|
||||
obj.createNestedObject("nested");
|
||||
obj["nested"].to<JsonObject>();
|
||||
REQUIRE(obj.nesting() == 2);
|
||||
}
|
||||
}
|
||||
|
@ -32,26 +32,6 @@ TEST_CASE("std::string") {
|
||||
REQUIRE(std::string("value") == obj[std::string("key")]);
|
||||
}
|
||||
|
||||
SECTION("createNestedObject()") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
std::string key = "key";
|
||||
char json[64];
|
||||
obj.createNestedObject(key);
|
||||
eraseString(key);
|
||||
serializeJson(doc, json, sizeof(json));
|
||||
REQUIRE(std::string("{\"key\":{}}") == json);
|
||||
}
|
||||
|
||||
SECTION("createNestedArray()") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
std::string key = "key";
|
||||
char json[64];
|
||||
obj.createNestedArray(key);
|
||||
eraseString(key);
|
||||
serializeJson(doc, json, sizeof(json));
|
||||
REQUIRE(std::string("{\"key\":[]}") == json);
|
||||
}
|
||||
|
||||
SECTION("containsKey()") {
|
||||
char json[] = "{\"key\":\"value\"}";
|
||||
deserializeJson(doc, json);
|
||||
|
@ -245,7 +245,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
#endif
|
||||
|
||||
SECTION("chain") {
|
||||
obj.createNestedObject("hello")["world"] = 123;
|
||||
obj["hello"]["world"] = 123;
|
||||
|
||||
REQUIRE(123 == obj["hello"]["world"].as<int>());
|
||||
REQUIRE(true == obj["hello"]["world"].is<int>());
|
||||
|
@ -92,13 +92,13 @@ TEST_CASE("serializeJson(JsonArray)") {
|
||||
}
|
||||
|
||||
SECTION("OneEmptyNestedArray") {
|
||||
array.createNestedArray();
|
||||
array.add<JsonArray>();
|
||||
|
||||
check(array, "[[]]");
|
||||
}
|
||||
|
||||
SECTION("OneEmptyNestedHash") {
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
check(array, "[{}]");
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ TEST_CASE("serializeJsonPretty(JsonArray)") {
|
||||
}
|
||||
|
||||
SECTION("EmptyNestedArrays") {
|
||||
array.createNestedArray();
|
||||
array.createNestedArray();
|
||||
array.add<JsonArray>();
|
||||
array.add<JsonArray>();
|
||||
|
||||
checkArray(array,
|
||||
"[\r\n"
|
||||
@ -54,11 +54,11 @@ TEST_CASE("serializeJsonPretty(JsonArray)") {
|
||||
}
|
||||
|
||||
SECTION("NestedArrays") {
|
||||
JsonArray nested1 = array.createNestedArray();
|
||||
JsonArray nested1 = array.add<JsonArray>();
|
||||
nested1.add(1);
|
||||
nested1.add(2);
|
||||
|
||||
JsonObject nested2 = array.createNestedObject();
|
||||
JsonObject nested2 = array.add<JsonObject>();
|
||||
nested2["key"] = 3;
|
||||
|
||||
checkArray(array,
|
||||
|
@ -99,7 +99,7 @@ TEST_CASE("serializeJson(JsonObject)") {
|
||||
JsonDocument b;
|
||||
JsonDocument c;
|
||||
|
||||
obj.createNestedArray("a");
|
||||
obj["a"].to<JsonArray>();
|
||||
obj["b"] = b.to<JsonArray>();
|
||||
obj["c"] = c.to<JsonArray>();
|
||||
|
||||
@ -110,7 +110,7 @@ TEST_CASE("serializeJson(JsonObject)") {
|
||||
JsonDocument b;
|
||||
JsonDocument c;
|
||||
|
||||
obj.createNestedObject("a");
|
||||
obj["a"].to<JsonObject>();
|
||||
obj["b"] = b.to<JsonObject>();
|
||||
obj["c"] = c.to<JsonObject>();
|
||||
|
||||
|
@ -47,8 +47,8 @@ TEST_CASE("serializeJsonPretty(JsonObject)") {
|
||||
}
|
||||
|
||||
SECTION("EmptyNestedContainers") {
|
||||
obj.createNestedObject("key1");
|
||||
obj.createNestedArray("key2");
|
||||
obj["key1"].to<JsonObject>();
|
||||
obj["key2"].to<JsonArray>();
|
||||
|
||||
checkObjectPretty(obj,
|
||||
"{\r\n"
|
||||
@ -58,10 +58,10 @@ TEST_CASE("serializeJsonPretty(JsonObject)") {
|
||||
}
|
||||
|
||||
SECTION("NestedContainers") {
|
||||
JsonObject nested1 = obj.createNestedObject("key1");
|
||||
JsonObject nested1 = obj["key1"].to<JsonObject>();
|
||||
nested1["a"] = 1;
|
||||
|
||||
JsonArray nested2 = obj.createNestedArray("key2");
|
||||
JsonArray nested2 = obj["key2"].to<JsonArray>();
|
||||
nested2.add(2);
|
||||
|
||||
checkObjectPretty(obj,
|
||||
|
@ -10,7 +10,6 @@ add_executable(JsonVariantTests
|
||||
containsKey.cpp
|
||||
converters.cpp
|
||||
copy.cpp
|
||||
createNested.cpp
|
||||
is.cpp
|
||||
isnull.cpp
|
||||
misc.cpp
|
||||
|
@ -16,7 +16,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") {
|
||||
|
||||
SECTION("stores JsonArray by copy") {
|
||||
JsonArray arr = doc2.to<JsonArray>();
|
||||
JsonObject obj = arr.createNestedObject();
|
||||
JsonObject obj = arr.add<JsonObject>();
|
||||
obj["hello"] = "world";
|
||||
|
||||
var1.set(arr);
|
||||
@ -27,7 +27,7 @@ TEST_CASE("JsonVariant::set(JsonVariant)") {
|
||||
|
||||
SECTION("stores JsonObject by copy") {
|
||||
JsonObject obj = doc2.to<JsonObject>();
|
||||
JsonArray arr = obj.createNestedArray("value");
|
||||
JsonArray arr = obj["value"].to<JsonArray>();
|
||||
arr.add(42);
|
||||
|
||||
var1.set(obj);
|
||||
|
@ -1,58 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <stdint.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("JsonVariant::createNestedObject()") {
|
||||
JsonDocument doc;
|
||||
JsonVariant variant = doc.to<JsonVariant>();
|
||||
|
||||
SECTION("promotes to array") {
|
||||
JsonObject obj = variant.createNestedObject();
|
||||
obj["value"] = 42;
|
||||
|
||||
REQUIRE(variant.is<JsonArray>() == true);
|
||||
REQUIRE(variant[0]["value"] == 42);
|
||||
REQUIRE(obj.isNull() == false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonVariant::createNestedArray()") {
|
||||
JsonDocument doc;
|
||||
JsonVariant variant = doc.to<JsonVariant>();
|
||||
|
||||
SECTION("promotes to array") {
|
||||
JsonArray arr = variant.createNestedArray();
|
||||
|
||||
REQUIRE(variant.is<JsonArray>() == true);
|
||||
REQUIRE(arr.isNull() == false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonVariant::createNestedObject(key)") {
|
||||
JsonDocument doc;
|
||||
JsonVariant variant = doc.to<JsonVariant>();
|
||||
|
||||
SECTION("promotes to object") {
|
||||
JsonObject obj = variant.createNestedObject("weather");
|
||||
obj["temp"] = 42;
|
||||
|
||||
REQUIRE(variant.is<JsonObject>() == true);
|
||||
REQUIRE(variant["weather"]["temp"] == 42);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonVariant::createNestedArray(key)") {
|
||||
JsonDocument doc;
|
||||
JsonVariant variant = doc.to<JsonVariant>();
|
||||
|
||||
SECTION("promotes to object") {
|
||||
JsonArray arr = variant.createNestedArray("items");
|
||||
|
||||
REQUIRE(variant.is<JsonObject>() == true);
|
||||
REQUIRE(arr.isNull() == false);
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ TEST_CASE("JsonVariant::operator[]") {
|
||||
}
|
||||
|
||||
SECTION("set value in a nested object") {
|
||||
array.createNestedObject();
|
||||
array.add<JsonObject>();
|
||||
|
||||
var[0]["hello"] = "world";
|
||||
|
||||
|
@ -193,22 +193,6 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
REQUIRE(0 == obj.size());
|
||||
}
|
||||
|
||||
SECTION("createNestedArray()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj.createNestedArray(key);
|
||||
}
|
||||
|
||||
SECTION("createNestedObject()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj.createNestedObject(key);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("MemberProxy") {
|
||||
|
@ -12,8 +12,6 @@ measureMsgPack KEYWORD2
|
||||
# Methods
|
||||
add KEYWORD2
|
||||
as KEYWORD2
|
||||
createNestedArray KEYWORD2
|
||||
createNestedObject KEYWORD2
|
||||
get KEYWORD2
|
||||
set KEYWORD2
|
||||
to KEYWORD2
|
||||
|
@ -130,16 +130,6 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
|
||||
return {*this, index};
|
||||
}
|
||||
|
||||
// Creates an object and appends it to the array.
|
||||
// https://arduinojson.org/v6/api/jsonarray/createnestedobject/
|
||||
FORCE_INLINE JsonObject createNestedObject() const;
|
||||
|
||||
// Creates an array and appends it to the array.
|
||||
// https://arduinojson.org/v6/api/jsonarray/createnestedarray/
|
||||
FORCE_INLINE JsonArray createNestedArray() const {
|
||||
return add<JsonArray>();
|
||||
}
|
||||
|
||||
operator JsonVariantConst() const {
|
||||
return JsonVariantConst(collectionToVariant(data_), resources_);
|
||||
}
|
||||
|
@ -7,26 +7,8 @@
|
||||
#include <ArduinoJson/Array/JsonArray.hpp>
|
||||
#include <ArduinoJson/Object/JsonObject.hpp>
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
inline JsonObject JsonArray::createNestedObject() const {
|
||||
return add<JsonObject>();
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TDerived>
|
||||
inline JsonArray VariantRefBase<TDerived>::createNestedArray() const {
|
||||
return add<JsonArray>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
inline JsonObject VariantRefBase<TDerived>::createNestedObject() const {
|
||||
return add<JsonObject>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
inline ElementProxy<TDerived> VariantRefBase<TDerived>::operator[](
|
||||
size_t index) const {
|
||||
|
@ -152,46 +152,6 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
|
||||
return getVariant().template to<T>();
|
||||
}
|
||||
|
||||
// Creates an array and appends it to the root array.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedarray/
|
||||
JsonArray createNestedArray() {
|
||||
return add<JsonArray>();
|
||||
}
|
||||
|
||||
// Creates an array and adds it to the root object.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedarray/
|
||||
template <typename TChar>
|
||||
JsonArray createNestedArray(TChar* key) {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
// Creates an array and adds it to the root object.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedarray/
|
||||
template <typename TString>
|
||||
JsonArray createNestedArray(const TString& key) {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
// Creates an object and appends it to the root array.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedobject/
|
||||
JsonObject createNestedObject() {
|
||||
return add<JsonObject>();
|
||||
}
|
||||
|
||||
// Creates an object and adds it to the root object.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedobject/
|
||||
template <typename TChar>
|
||||
JsonObject createNestedObject(TChar* key) {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
// Creates an object and adds it to the root object.
|
||||
// https://arduinojson.org/v6/api/jsondocument/createnestedobject/
|
||||
template <typename TString>
|
||||
JsonObject createNestedObject(const TString& key) {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
// Returns true if the root object contains the specified key.
|
||||
// https://arduinojson.org/v6/api/jsondocument/containskey/
|
||||
template <typename TChar>
|
||||
|
@ -166,30 +166,6 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
resources_) != 0;
|
||||
}
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/createnestedarray/
|
||||
template <typename TString>
|
||||
FORCE_INLINE JsonArray createNestedArray(const TString& key) const;
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/createnestedarray/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE JsonArray createNestedArray(TChar* key) const;
|
||||
|
||||
// Creates an object and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/createnestedobject/
|
||||
template <typename TString>
|
||||
JsonObject createNestedObject(const TString& key) const {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
// Creates an object and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/createnestedobject/
|
||||
template <typename TChar>
|
||||
JsonObject createNestedObject(TChar* key) const {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
private:
|
||||
detail::ResourceManager* getResourceManager() const {
|
||||
return resources_;
|
||||
|
@ -7,49 +7,8 @@
|
||||
#include <ArduinoJson/Array/JsonArray.hpp>
|
||||
#include <ArduinoJson/Object/JsonObject.hpp>
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
template <typename TString>
|
||||
inline JsonArray JsonObject::createNestedArray(const TString& key) const {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
template <typename TChar>
|
||||
inline JsonArray JsonObject::createNestedArray(TChar* key) const {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline JsonArray VariantRefBase<TDerived>::createNestedArray(
|
||||
const TString& key) const {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TChar>
|
||||
inline JsonArray VariantRefBase<TDerived>::createNestedArray(TChar* key) const {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline JsonObject VariantRefBase<TDerived>::createNestedObject(
|
||||
const TString& key) const {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TChar>
|
||||
inline JsonObject VariantRefBase<TDerived>::createNestedObject(
|
||||
TChar* key) const {
|
||||
return operator[](key).template to<JsonObject>();
|
||||
}
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString>::value, bool>::type
|
||||
|
@ -191,14 +191,6 @@ class VariantRefBase : public VariantTag {
|
||||
getResourceManager());
|
||||
}
|
||||
|
||||
// Creates an array and appends it to the array.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedarray/
|
||||
FORCE_INLINE JsonArray createNestedArray() const;
|
||||
|
||||
// Creates an object and appends it to the array.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedobject/
|
||||
FORCE_INLINE JsonObject createNestedObject() const;
|
||||
|
||||
// Gets or sets an array element.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/subscript/
|
||||
FORCE_INLINE ElementProxy<TDerived> operator[](size_t index) const;
|
||||
@ -229,26 +221,6 @@ class VariantRefBase : public VariantTag {
|
||||
MemberProxy<TDerived, TChar*>>::type
|
||||
operator[](TChar* key) const;
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedarray/
|
||||
template <typename TString>
|
||||
FORCE_INLINE JsonArray createNestedArray(const TString& key) const;
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedarray/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE JsonArray createNestedArray(TChar* key) const;
|
||||
|
||||
// Creates an object and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedobject/
|
||||
template <typename TString>
|
||||
JsonObject createNestedObject(const TString& key) const;
|
||||
|
||||
// Creates an object and adds it to the object.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/createnestedobject/
|
||||
template <typename TChar>
|
||||
JsonObject createNestedObject(TChar* key) const;
|
||||
|
||||
private:
|
||||
TDerived& derived() {
|
||||
return static_cast<TDerived&>(*this);
|
||||
|
Reference in New Issue
Block a user