Removed JsonPair constructor

This commit is contained in:
Benoit Blanchon
2014-11-05 09:31:29 +01:00
parent 8ac4346fd5
commit 5d0e326bfd
4 changed files with 8 additions and 9 deletions

View File

@ -12,7 +12,7 @@ namespace ArduinoJson {
namespace Internals { namespace Internals {
struct JsonObjectNode { struct JsonObjectNode {
JsonObjectNode(const char* key) : content(key), next(NULL) {} JsonObjectNode() : next(NULL) {}
JsonPair content; JsonPair content;
JsonObjectNode* next; JsonObjectNode* next;

View File

@ -67,7 +67,7 @@ class JsonObject : public Internals::JsonPrintable<JsonObject>,
JsonObject(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {} JsonObject(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {}
JsonVariant &add(key_type key) { return (*this)[key]; } JsonVariant &add(key_type key) { return (*this)[key]; }
Internals::JsonObjectNode *createNode(key_type key); Internals::JsonObjectNode *createNode();
void addNode(Internals::JsonObjectNode *nodeToAdd); void addNode(Internals::JsonObjectNode *nodeToAdd);
void removeNode(Internals::JsonObjectNode *nodeToRemove); void removeNode(Internals::JsonObjectNode *nodeToRemove);

View File

@ -11,8 +11,6 @@
namespace ArduinoJson { namespace ArduinoJson {
struct JsonPair { struct JsonPair {
JsonPair(const char* k) : key(k) {}
const char* key; const char* key;
JsonVariant value; JsonVariant value;
}; };

View File

@ -67,17 +67,18 @@ JsonObjectNode *JsonObject::getOrCreateNodeAt(const char *key) {
JsonObjectNode *existingNode = getNodeAt(key); JsonObjectNode *existingNode = getNodeAt(key);
if (existingNode) return existingNode; if (existingNode) return existingNode;
JsonObjectNode *newNode = createNode(key); JsonObjectNode *newNode = createNode();
if (!newNode) return NULL;
if (newNode) addNode(newNode);
newNode->content.key = key;
addNode(newNode);
return newNode; return newNode;
} }
JsonObjectNode *JsonObject::createNode(const char *key) { JsonObjectNode *JsonObject::createNode() {
if (!_buffer) return NULL; if (!_buffer) return NULL;
void *ptr = _buffer->alloc(sizeof(JsonObjectNode)); void *ptr = _buffer->alloc(sizeof(JsonObjectNode));
return ptr ? new (ptr) JsonObjectNode(key) : NULL; return ptr ? new (ptr) JsonObjectNode() : NULL;
} }
void JsonObject::addNode(JsonObjectNode *nodeToAdd) { void JsonObject::addNode(JsonObjectNode *nodeToAdd) {