|
|
@@ -19,22 +19,20 @@ namespace ArduinoJson
|
|
|
template<typename T>
|
|
|
void add(const char* key, T value)
|
|
|
{
|
|
|
- if (count >= capacity) return;
|
|
|
+ KeyValuePair* pair = getMatchingPair(key);
|
|
|
+ if (!pair) return;
|
|
|
|
|
|
- items[count].key.set(key);
|
|
|
- items[count].value.set(value);
|
|
|
- count++;
|
|
|
+ pair->value.set(value);
|
|
|
}
|
|
|
|
|
|
template<int DIGITS>
|
|
|
void add(const char* key, double value)
|
|
|
{
|
|
|
- if (count >= capacity) return;
|
|
|
+ KeyValuePair* pair = getMatchingPair(key);
|
|
|
+ if (!pair) return;
|
|
|
|
|
|
- items[count].key.set(key);
|
|
|
- items[count].value.set<DIGITS>(value);
|
|
|
- count++;
|
|
|
- }
|
|
|
+ pair->value.set<DIGITS>(value);
|
|
|
+ }
|
|
|
|
|
|
using JsonPrintable::printTo;
|
|
|
|
|
|
@@ -53,6 +51,8 @@ namespace ArduinoJson
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+ KeyValuePair* getMatchingPair(const char* key);
|
|
|
+
|
|
|
private:
|
|
|
KeyValuePair* items;
|
|
|
int capacity, count;
|