#includeUsing namespace std; JsonObject jsonObj; jsonObj["name"] = "John"; jsonObj["age"] = 25;
#includeUsing namespace std; String jsonString = "{\"name\":\"John\",\"age\":25}"; StaticJsonDocument<200> doc; deserializeJson(doc, jsonString); JsonObject jsonObj = doc.as (); String name = jsonObj["name"]; int age = jsonObj["age"];
#includeIn this example, we are creating a JSON object with two nested JSON objects - "nestedObject1" and "nestedObject2". We first create each nested object with its own properties, then assign these objects to the parent JSON object by name. Overall, the ArduinoJson package including the JsonObject library is a useful tool for easily handling JSON objects in C++.Using namespace std; JsonObject jsonObj; JsonObject nestedObj1; nestedObj1["property1"] = 5; nestedObj1["property2"] = "hello"; JsonObject nestedObj2; nestedObj2["property1"] = 10; nestedObj2["property2"] = "world"; jsonObj["nestedObject1"] = nestedObj1; jsonObj["nestedObject2"] = nestedObj2;