JsonPrintable.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Arduino JSON library
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #pragma once
  6. #include "Print.h"
  7. #include "Printable.h"
  8. #include "IndentedPrint.h"
  9. namespace ArduinoJson
  10. {
  11. namespace Generator
  12. {
  13. // Contains methods to generate a JSON string.
  14. // Implemented by both JsonObject and JsonArray
  15. class JsonPrintable : public Printable
  16. {
  17. public:
  18. // Generates the compact JSON string and sends it to a Print stream
  19. virtual size_t printTo(Print& p) const = 0;
  20. // Generates the compact JSON string and writes it in a buffer
  21. size_t printTo(char* buffer, size_t bufferSize) const;
  22. // Generates the indented JSON string and sends it to a Print stream
  23. size_t prettyPrintTo(Print& p) const;
  24. // Generates the indented JSON string and sends it to a IndentedPrint stream
  25. // This overload allows a finer control of the output because you can customize
  26. // the IndentedPrint.
  27. size_t prettyPrintTo(IndentedPrint& p) const;
  28. // Generates the indented JSON string and writes it in a buffer
  29. size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
  30. };
  31. }
  32. }