Files
ArduinoJson/JsonGenerator/JsonObjectBase.cpp

36 lines
665 B
C++
Raw Normal View History

2014-07-08 21:29:19 +02:00
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
2014-07-22 21:02:16 +02:00
#include "JsonObjectBase.h"
using namespace ArduinoJson::Generator;
2014-07-22 21:02:16 +02:00
size_t JsonObjectBase::printTo(Print& p) const
{
size_t n = 0;
n += p.write('{');
2014-07-08 21:29:19 +02:00
// NB: the code has been optimized for a small size on a 8-bit AVR
const KeyValuePair* current = items;
for (int i = count; i > 0; i--)
{
n += current->key.printTo(p);
n += p.write(':');
n += current->value.printTo(p);
current++;
if (i > 1)
{
n += p.write(',');
}
}
n += p.write('}');
return n;
}