mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
Support ElementProxy
and MemberProxy
in JsonDocument
's constructor
This commit is contained in:
@ -126,4 +126,22 @@ TEST_CASE("JsonDocument constructor") {
|
||||
|
||||
REQUIRE(doc2.as<std::string>() == "hello");
|
||||
}
|
||||
|
||||
SECTION("JsonDocument(ElementProxy)") {
|
||||
JsonDocument doc1;
|
||||
deserializeJson(doc1, "[\"hello\",\"world\"]");
|
||||
|
||||
JsonDocument doc2(doc1[1]);
|
||||
|
||||
REQUIRE(doc2.as<std::string>() == "world");
|
||||
}
|
||||
|
||||
SECTION("JsonDocument(MemberProxy)") {
|
||||
JsonDocument doc1;
|
||||
deserializeJson(doc1, "{\"hello\":\"world\"}");
|
||||
|
||||
JsonDocument doc2(doc1["hello"]);
|
||||
|
||||
REQUIRE(doc2.as<std::string>() == "world");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user