A RetroSearch Logo

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

Search Query:

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

JsonObject::createNestedObject() | ArduinoJson 6

Description

JsonObject::createNestedObject() appends a new object to the object pointed by the JsonObject.

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

Signature
JsonObject createNestedObject(char* key) const;
JsonObject createNestedObject(const char* key) const;  // ⚠️ stores key as a pointer
JsonObject createNestedObject(const __FlashStringHelper* key) const;

JsonObject createNestedObject(const String& key) const;
JsonObject createNestedObject(const std::string& key) const;
JsonObject createNestedObject(std::string_view key) const;
Arguments

key: the key to associate with the new object.

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

Return value

JsonObject::createNestedObject() returns a JsonObject that points to the newly created object.

JsonObject::createNestedObject() returns null if the memory allocation fails; in which case JsonObject::isNull(), returns true.

Example
StaticJsonDocument<256> doc;
JsonObject root = doc.to<JsonObject>();
root["city"] = "Paris";
JsonObject weather = root.createNestedObject("weather");
weather["temp"] = 14.2;
weather["cond"] = "cloudy";
serializeJsonPretty(root, Serial);

will print

{
  "city": "Paris",
  "weather": {
    "temp": 14.20,
    "cond": "cloudy"
  }
}
See also
  1. Home
  2. Version 6
  3. API
  4. JsonObject
  5. createNestedObject()

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