JsonArrayBase.cpp 629 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Arduino JSON library
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #include "JsonArrayBase.h"
  6. using namespace ArduinoJson::Generator;
  7. using namespace ArduinoJson::Internals;
  8. size_t JsonArrayBase::printTo(Print& p) const
  9. {
  10. size_t n = 0;
  11. n += p.write('[');
  12. // NB: the code has been optimized for a small size on a 8-bit AVR
  13. const JsonValue* current = items;
  14. for (int i = count; i > 0; i--)
  15. {
  16. n += current->printTo(p);
  17. current++;
  18. if (i > 1)
  19. {
  20. n += p.write(',');
  21. }
  22. }
  23. n += p.write(']');
  24. return n;
  25. }