Description

Adds a new nested object to the end of the array.

Signature

JsonObject createNestedObject();

Return value

A reference to the new JsonObject. You can check JsonObject::isNull() to verify that the allocation succeeded.

Example

StaticJsonDocument<200> doc;
JsonArray array = doc.to<JsonArray>();
JsonObject nested = array.createNestedObject();
nested["hello"] = "world";
serializeJson(array, Serial);

will write

[{"hello":"world"}]

See also