| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- * Arduino JSON library
- * Benoit Blanchon 2014 - MIT License
- */
- #include "JsonObjectBase.h"
- using namespace ArduinoJson::Generator;
- size_t JsonObjectBase::printTo(Print& p) const
- {
- size_t n = 0;
- n += p.write('{');
- // 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;
- }
- JsonObjectBase::KeyValuePair* JsonObjectBase::getMatchingPair(char const* key)
- {
- for (int i = 0; i < count; ++i)
- {
- if (items[i].key.equals(key))
- {
- return &items[i];
- }
- }
- if (count >= capacity) return 0;
-
- KeyValuePair* p = &items[count++];
- p->key.set(key);
- return p;
- }
|