mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	remove()
This commit is contained in:
		| @@ -39,7 +39,7 @@ TEST_CASE("JsonVariant::memoryUsage()") { | ||||
|     REQUIRE(var.memoryUsage() == doc.memoryUsage()); | ||||
|   } | ||||
|  | ||||
|   SECTION("ignore size of link document") { | ||||
|   SECTION("ignore size of linked document") { | ||||
|     StaticJsonDocument<128> doc2; | ||||
|     doc2["hello"] = "world"; | ||||
|     var.link(doc2); | ||||
|   | ||||
| @@ -39,4 +39,24 @@ TEST_CASE("JsonVariant::remove()") { | ||||
|  | ||||
|     REQUIRE(var.as<std::string>() == "{\"a\":1}"); | ||||
|   } | ||||
|  | ||||
|   SECTION("linked array") { | ||||
|     StaticJsonDocument<128> doc2; | ||||
|     doc2[0] = 42; | ||||
|     var.link(doc2); | ||||
|  | ||||
|     var.remove(0); | ||||
|  | ||||
|     CHECK(var.as<std::string>() == "[42]"); | ||||
|   } | ||||
|  | ||||
|   SECTION("linked object") { | ||||
|     StaticJsonDocument<128> doc2; | ||||
|     doc2["hello"] = "world"; | ||||
|     var.link(doc2); | ||||
|  | ||||
|     var.remove("hello"); | ||||
|  | ||||
|     CHECK(var.as<std::string>() == "{\"hello\":\"world\"}"); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -177,13 +177,13 @@ class VariantData { | ||||
|   } | ||||
|  | ||||
|   void remove(size_t index) { | ||||
|     if (isArray()) | ||||
|     if (isArrayStrict()) | ||||
|       _content.asCollection.removeElement(index); | ||||
|   } | ||||
|  | ||||
|   template <typename TAdaptedString> | ||||
|   void remove(TAdaptedString key) { | ||||
|     if (isObject()) | ||||
|     if (isObjectStrict()) | ||||
|       _content.asCollection.removeMember(key); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user