Description

JsonVariant::createNestedArray() adds a new array as a child of the JsonVariant. This function reproduces JsonArray::createNestedArray() or JsonObject::createNestedArray() depending on the argument.

The call is ignored of the JsonVariant is incompatible with the operation. For example, if you call JsonVariant::createNestedArray() without argument on a JsonVariant that contains an object, the function does nothing.

Signature

// similar to JsonArray::createNestedArray()
JsonArray createNestedArray() const;

// similar to JsonObject::createNestedArray()
JsonArray createNestedArray(char* key) const;
JsonArray createNestedArray(const char* key) const;
JsonArray createNestedArray(const __FlashStringHelper* key) const;
JsonArray createNestedArray(const String& key) const;
JsonArray createNestedArray(const std::string& key) const;
JsonArray createNestedArray(std::string_view key) const;  // 🆕 (added in 6.18.1)

Return value

JsonVariant::createNestedArray() returns a JsonArray that points to the new array.

JsonVariant::createNestedArray() returns null when the memory allocation fails; in which case JsonArray::isNull() return true.

See also