JsonArray
Description
A collection of JsonVariant
The constructor is private; you cannot instantiate a JsonArray
directly.
Instead, you must use JsonBuffer::createArray()
.
Because the memory of a JsonArray
is located a JsonBuffer
, 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
StaticJsonBuffer<200> jsonBuffer;
// create an empty array
JsonArray& array1 = jsonBuffer.createArray();
// parse a JSON array
char json[] = "[1,2,3]";
JsonArray& array2 = jsonBuffer.parseArray(json);
Member functions
JsonArray::add()
JsonArray::begin() / JsonArray::end()
JsonArray::copyFrom()
JsonArray::copyTo()
JsonArray::createNestedArray()
JsonArray::createNestedObject()
JsonArray::get<T>()
JsonArray::is<T>()
JsonArray::measureLength()
JsonArray::measurePrettyLength()
JsonArray::prettyPrintTo()
JsonArray::printTo()
JsonArray::remove()
JsonArray::set()
JsonArray::size()
JsonArray::operator[]
JsonArray::success()
See also
JsonBuffer::createArray()
JsonBuffer::parseArray()
JsonObject
JsonVariant
- Serialization tutorial
- Deserialization tutorial
Keep learning
The book Mastering ArduinoJson is the best material to learn how to use ArduinoJson.
Chapter 3 is a tutorial on deserialization; it explains the various ways to convert an input JSON document into a JsonArray
.
Chapter 4 is a tutorial on serialization; it explains the various ways to convert a JsonArray
into a JSON document.
Chapter 5 explains how JsonArray
is implemented.