Test that JsonArray grows after calling add()

This commit is contained in:
Benoit Blanchon
2014-10-05 14:48:19 +02:00
parent cb3c59ec07
commit 4c67d0579a
5 changed files with 22 additions and 15 deletions

View File

@ -38,16 +38,12 @@ JsonNode* JsonObject::getOrCreateNodeAt(const char* key)
{
if (!checkNodeType(JSON_OBJECT)) return 0;
JsonNode* lastChild = 0;
for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
{
const char* childKey = it->content.asKey.key;
if (!strcmp(childKey, key))
return it->content.asKey.value;
lastChild = *it;
}
JsonNode* newValueNode = createNode(JSON_UNDEFINED);
@ -59,7 +55,7 @@ JsonNode* JsonObject::getOrCreateNodeAt(const char* key)
newKeyNode->content.asKey.key = key;
newKeyNode->content.asKey.value = newValueNode;
insertChildAfter(newKeyNode, lastChild);
addChild(newKeyNode);
return newValueNode;
}