Description

A collection of named JsonVariant.

The constructor is private; you cannot instantiate a JsonObject directly, you have to use a JsonBuffer.

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

Computing the size

The macro JSON_OBJECT_SIZE(n) returns the size of a JsonObject that contains n elements. This value only includes the size of the JsonObject; 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 object
JsonObject& object1 = jsonBuffer.createObject();
object1["hello"] = "world";

// parse a JSON object
char json[] = "{\"hello\":\"world\"}";
JsonObject& object2 = jsonBuffer.parseObject(json);

Member functions

See also

Keep learning

Mastering ArduinoJson

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 JsonObject.

Chapter 4 is a tutorial on serialization; it explains the various ways to convert a JsonObject into a JSON document.

Chapter 5 explains how JsonObject is implemented.

Global warming stripes by Professor Ed Hawkins (University of Reading)