JsonGeneratorExample.ino 624 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Arduino JSON library - Generator example
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #include <JsonGenerator.h>
  6. using namespace ArduinoJson::Generator;
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. JsonArray<2> array;
  11. array.add<6>(48.756080); // 6 is the number of decimals to print
  12. array.add<6>(2.302038); // if not specified, 2 digits are printed
  13. JsonHashTable<3> root;
  14. root.add("sensor", "gps");
  15. root.add("time", 1351824120);
  16. root.add("data", array);
  17. Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
  18. }
  19. void loop()
  20. {
  21. }