diff --git a/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/examples/JsonGeneratorExample/JsonGeneratorExample.ino index f7b1d3ad..d8656e6b 100644 --- a/examples/JsonGeneratorExample/JsonGeneratorExample.ino +++ b/examples/JsonGeneratorExample/JsonGeneratorExample.ino @@ -11,14 +11,13 @@ void setup() { StaticJsonBuffer<200> jsonBuffer; - JsonArray& array = jsonBuffer.createArray(); - array.add(48.756080, 6); // 6 is the number of decimals to print - array.add(2.302038, 6); // if not specified, 2 digits are printed - JsonObject& root = jsonBuffer.createObject(); root["sensor"] = "gps"; root["time"] = 1351824120; - root["data"] = array; + + JsonArray& data = root.createNestedArray("data"); + data.add(48.756080, 6); // 6 is the number of decimals to print + data.add(2.302038, 6); // if not specified, 2 digits are printed root.printTo(Serial); // This prints: