JsonGeneratorExample.ino 694 B

1234567891011121314151617181920212223242526272829303132
  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. JsonObject<3> root;
  14. root["sensor"] = "gps";
  15. root["time"] = 1351824120;
  16. root["data"] = array;
  17. Serial.print(root); // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
  18. Serial.println();
  19. root.prettyPrintTo(Serial); // same string indented
  20. }
  21. void loop()
  22. {
  23. }