Files
ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino

29 lines
612 B
Arduino
Raw Normal View History

/*
2014-07-05 13:10:07 +02:00
* Arduino JSON library - Generator example
* Benoit Blanchon 2014 - MIT License
*/
#include <JsonGenerator.h>
2014-07-03 13:54:27 +02:00
using namespace ArduinoJson::Generator;
void setup()
{
Serial.begin(9600);
2014-07-05 21:39:56 +02:00
JsonArray<2> array;
2014-07-07 16:22:43 +02:00
array.add<6>(48.756080); // 6 is the number of decimals to print
array.add<6>(2.302038); // if not specified, 2 digits are printed
2014-07-22 21:02:16 +02:00
JsonObject<3> root;
2014-07-31 20:16:14 +02:00
root["sensor"] = "gps";
root["time"] = 1351824120;
root["data"] = array;
2014-07-05 21:39:56 +02:00
Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
}
void loop()
{
2014-07-05 13:10:07 +02:00
}