forked from bblanchon/ArduinoJson
Added JsonObjectBase::remove()
This commit is contained in:
@ -81,4 +81,12 @@ JsonValue& JsonObjectBase::operator[](JsonKey key)
|
||||
bool JsonObjectBase::containsKey(JsonKey key) const
|
||||
{
|
||||
return getMatchingPair(key) != 0;
|
||||
}
|
||||
|
||||
void JsonObjectBase::remove(JsonKey key)
|
||||
{
|
||||
KeyValuePair* match = getMatchingPair(key);
|
||||
if (match == 0) return;
|
||||
|
||||
*match = items[--count];
|
||||
}
|
@ -18,8 +18,8 @@ namespace ArduinoJson
|
||||
{
|
||||
public:
|
||||
JsonValue& operator[](JsonKey);
|
||||
|
||||
bool containsKey(JsonKey) const;
|
||||
void remove(JsonKey key);
|
||||
|
||||
template<typename T>
|
||||
void add(JsonKey key, T value)
|
||||
@ -53,7 +53,6 @@ namespace ArduinoJson
|
||||
private:
|
||||
KeyValuePair* items;
|
||||
int capacity, count;
|
||||
|
||||
static JsonValue nullValue;
|
||||
|
||||
KeyValuePair* getMatchingPair(JsonKey key) const;
|
||||
|
Reference in New Issue
Block a user