2014-07-01 14:08:15 +02:00
|
|
|
/*
|
2014-07-05 13:10:07 +02:00
|
|
|
* Arduino JSON library - Generator example
|
2014-07-01 14:08:15 +02:00
|
|
|
* Benoit Blanchon 2014 - MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <JsonGenerator.h>
|
|
|
|
|
2014-07-03 13:54:27 +02:00
|
|
|
using namespace ArduinoJson::Generator;
|
|
|
|
|
2014-07-01 14:08:15 +02:00
|
|
|
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-01 14:08:15 +02:00
|
|
|
|
2014-07-05 21:39:56 +02:00
|
|
|
JsonHashTable<3> root;
|
|
|
|
root.add("sensor", "gps");
|
|
|
|
root.add("time", 1351824120);
|
|
|
|
root.add("data", array);
|
|
|
|
|
|
|
|
Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
2014-07-01 14:08:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
|
2014-07-05 13:10:07 +02:00
|
|
|
}
|