JsonVariantConst is an immutable version of JsonVariant; only use it if you want to enforce immutability.

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.

Signatures

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

// mimics a JsonObjectConst
JsonObjectConst operator[](const char* key) const;
JsonObjectConst operator[](char* key) const;
JsonObjectConst operator[](const String& key) const;
JsonObjectConst operator[](const std::string& key) const;
JsonObjectConst 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