mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
Fix "no matching function" with JsonObjectConst::operator[]
Fixes #2019
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
ArduinoJson: change log
|
||||
=======================
|
||||
|
||||
HEAD
|
||||
----
|
||||
|
||||
* Fix "no matching function" with `JsonObjectConst::operator[]` (issue #2019)
|
||||
|
||||
v7.0.0 (2024-01-03)
|
||||
------
|
||||
|
||||
|
@ -252,3 +252,11 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
REQUIRE(false == obj["hello"]["world"].is<bool>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonObjectConst::operator[]") {
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
JsonObjectConst obj = doc.as<JsonObjectConst>();
|
||||
|
||||
REQUIRE(obj["hello"] == "world"); // issue #2019
|
||||
}
|
||||
|
@ -101,8 +101,9 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
|
||||
JsonVariantConst>::type
|
||||
operator[](TChar* key) const {
|
||||
return JsonVariantConst(
|
||||
detail::ObjectData::getMember(data_, detail::adaptString(key)));
|
||||
return JsonVariantConst(detail::ObjectData::getMember(
|
||||
data_, detail::adaptString(key), resources_),
|
||||
resources_);
|
||||
}
|
||||
|
||||
// DEPRECATED: always returns zero
|
||||
|
Reference in New Issue
Block a user