summaryrefslogtreecommitdiff
path: root/json-glib/json-object.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2012-10-27 11:48:58 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2012-10-27 11:48:58 +0100
commit9dfb5000cad954431165e836e203e561ccb79c66 (patch)
treed5021ced913e6e4853880f8c37c29c1742aa6988 /json-glib/json-object.c
parent615538100a42063ca0b84b5bb9c8a6a046a89e0b (diff)
downloadjson-glib-9dfb5000cad954431165e836e203e561ccb79c66.tar.gz
Consolidate null handling in JsonArray and JsonObject
A null value is not only valid for JSON_NODE_NULL nodes, but also for JSON_NODE_ARRAY and JSON_NODE_OBJECT nodes that do not have a JsonArray or a JsonObject set.
Diffstat (limited to 'json-glib/json-object.c')
-rw-r--r--json-glib/json-object.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/json-glib/json-object.c b/json-glib/json-object.c
index 8f55098..acb3c5a 100644
--- a/json-glib/json-object.c
+++ b/json-glib/json-object.c
@@ -652,7 +652,16 @@ json_object_get_null_member (JsonObject *object,
node = object_get_member_internal (object, member_name);
g_return_val_if_fail (node != NULL, FALSE);
- return JSON_NODE_TYPE (node) == JSON_NODE_NULL;
+ if (JSON_NODE_HOLDS_NULL (node))
+ return TRUE;
+
+ if (JSON_NODE_HOLDS_OBJECT (node))
+ return json_node_get_object (node) == NULL;
+
+ if (JSON_NODE_HOLDS_ARRAY (node))
+ return json_node_get_array (node) == NULL;
+
+ return FALSE;
}
/**