Made it possible to use const JsonObject&

This commit is contained in:
Benoit Blanchon committed 2014-11-03 14:33:33 +01:00
1 parent 54f9bd9572
commit 429d5011b4
2 files changed
+15 -3

No files matched your search

+11 -1
View File
@@ -27,6 +27,16 @@ int JsonObject::size() const {
}
JsonValue &JsonObject::at(const char *key) {
JsonObjectNode *node = getNodeAt(key);
return node ? node->pair.value : JsonValue::invalid();
}
const JsonValue &JsonObject::at(const char *key) const {
JsonObjectNode *node = getNodeAt(key);
return node ? node->pair.value : JsonValue::invalid();
}
JsonValue &JsonObject::operator[](const char *key) {
JsonObjectNode *node = getOrCreateNodeAt(key);
return node ? node->pair.value : JsonValue::invalid();
}
@@ -47,7 +57,7 @@ JsonObject &JsonObject::createNestedObject(const char *key) {
return object;
}
JsonObjectNode *JsonObject::getNodeAt(const char *key) {
JsonObjectNode *JsonObject::getNodeAt(const char *key) const {
for (JsonObjectNode *node = _firstNode; node; node = node->next) {
if (!strcmp(node->pair.key, key)) return node;
}