Description

JsonVariantConst::operator[] gets a value in the JsonVariantConst.

Depending on the argument type the JsonVariantConst can be used like an JsonArrayConst or a JsonObjectConst.

JsonVariantConst::operator[] is a read-only version of JsonVariant::operator[].

Signatures

// mimics a JsonArrayConst
JsonVariantConst operator[](size_t index) const;

// mimics a JsonObjectConst
JsonVariantConst operator[](const char* key) const;
JsonVariantConst operator[](char* key) const;
JsonVariantConst operator[](const String& key) const;
JsonVariantConst operator[](const std::string& key) const;
JsonVariantConst operator[](std::string_view key) const;
JsonVariantConst operator[](const __FlashStringHelper* key) const;

Arguments

index: the index in the JsonArray.

key: the key in the JsonObject

Return value

A JsonVariantConst that points to the object member or the array element (depending on the overload you called).

The returned JsonVariantConst can be null (i.e JsonVariantConst::isNull() returns true) if the index is out of range, the key is not in the object, or the original JsonVariantConst is null.

See also