Simplified generator example

This commit is contained in:
Benoit Blanchon
2014-11-07 16:23:21 +01:00
parent fe17706b6c
commit b4b475d692

View File

@ -11,14 +11,13 @@ void setup() {
StaticJsonBuffer<200> jsonBuffer; 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(); JsonObject& root = jsonBuffer.createObject();
root["sensor"] = "gps"; root["sensor"] = "gps";
root["time"] = 1351824120; 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); root.printTo(Serial);
// This prints: // This prints: