Description

A collection of JsonVariant

The constructor is private; you cannot instantiate a JsonArray directly. Instead, you must use JsonDocument::to<JsonArray>().

Because the memory of a JsonArray is located a JsonDocument, you always manipulate it through reference, and you cannot copy it.

Computing the size

The macro JSON_ARRAY_SIZE(n) returns the size of a JsonArray that contains n elements. This value only includes the size of the JsonArray; if you have nested objects or strings, you need to add their sizes as well.

You can use the ArduinoJson Assistant to generate the complete expression.

Example

StaticJsonDocument<200> doc;

// create an empty array
JsonArray array1 = doc.to<JsonArray>();

// parse a JSON array
char json[] = "[1,2,3]";
deserializeJson(doc, json);
JsonArray array2 = doc.as<JsonArray>();

Member functions

See also