forked from bblanchon/ArduinoJson
Reduced size by 2 bytes
This commit is contained in:
@ -29,16 +29,19 @@ const JsonVariant &JsonObject::at(const char *key) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonVariant &JsonObject::operator[](const char *key) {
|
JsonVariant &JsonObject::operator[](const char *key) {
|
||||||
node_type *existingNode = getNodeAt(key);
|
// try to find an existing node
|
||||||
if (existingNode) return existingNode->content.value;
|
node_type *node = getNodeAt(key);
|
||||||
|
|
||||||
node_type *newNode = createNode();
|
// not fount => create a new one
|
||||||
if (!newNode) return JsonVariant::invalid();
|
if (!node) {
|
||||||
|
node = createNode();
|
||||||
|
if (!node) return JsonVariant::invalid();
|
||||||
|
|
||||||
newNode->content.key = key;
|
node->content.key = key;
|
||||||
addNode(newNode);
|
addNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
return newNode->content.value;
|
return node->content.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonObject::remove(char const *key) { removeNode(getNodeAt(key)); }
|
void JsonObject::remove(char const *key) { removeNode(getNodeAt(key)); }
|
||||||
|
Reference in New Issue
Block a user