JsonVariant::operator[]
Description
JsonVariant::operator[]
gets, replaces, adds a value in the JsonVariant
.
Depending on the argument type the JsonVariant
can be used like a JsonArray
or a JsonObject
.
All values are stored by copy, except string literals which are stored by address.
The string copy policy has changed in ArduinoJson 7.3.
Signatures
// mimics a JsonArray
ElementProxy operator[](size_t index) const;
// mimics a JsonObject
MemberProxy operator[](const char (&key)[N]) const;
MemberProxy operator[](const char* key) const;
MemberProxy operator[](const String& key) const;
MemberProxy operator[](const std::string& key) const;
MemberProxy operator[](string_view key) const;
MemberProxy operator[](const __FlashStringHelper* key) const;
Arguments
index
: the index in the JsonArray
.
key
: the key in the JsonObject
Return value
A proxy class that allows using the JsonVariant
as an array or a dictionary. If this concept of proxy class is unfamiliar to you, just think of a JsonVariant
instead.
Please see JsonArray::operator[]
and JsonObject::operator[]
for explanations about ElementProxy
and MemberProxy
.