From b4b475d6927ac1cea830379f848165a2d1f9d0f1 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 7 Nov 2014 16:23:21 +0100 Subject: [PATCH] Simplified generator example --- examples/JsonGeneratorExample/JsonGeneratorExample.ino | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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: