A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v6/api/jsonobject/subscript/ below:

JsonObject::operator[] | ArduinoJson 6

Description

JsonObject::operator[] gets, replaces, or adds a value in the object pointed by the JsonObject.

If the JsonObject is null/unbound, this function does nothing.

If you need to know if the insertion succeed, use JsonVariant::set() instead.

Signatures
MemberProxy operator[](char* key) const;
MemberProxy operator[](const char* key) const;  // ⚠️ stores key as a pointer
MemberProxy operator[](const __FlashStringHelper* key) const;

MemberProxy operator[](const String& key) const;
MemberProxy operator[](const std::string& key) const;
MemberProxy operator[](std::string_view key) const;
Arguments

key: the key that the value will be associated with.

All types are stored by copy, except const char* which is stored by pointer.

Return value

JsonObject::operator[] return a proxy class that allows using the JsonObject like a dictionary.

If this concept of proxy class is unfamiliar to you, just think of a JsonVariant instead.

Example
StaticJsonDocument<256> doc;
JsonObject object = doc.to<JsonObject>();
object["hello"] = "world";
const char* world = object["hello"];
See also
  1. Home
  2. Version 6
  3. API
  4. JsonObject
  5. operator[]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4