summaryrefslogtreecommitdiff
path: root/json-glib/json-array.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-array.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-array.c')
-rw-r--r--json-glib/json-array.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/json-glib/json-array.c b/json-glib/json-array.c
index 3d5e47f..b353ea3 100644
--- a/json-glib/json-array.c
+++ b/json-glib/json-array.c
@@ -360,7 +360,16 @@ json_array_get_null_element (JsonArray *array,
node = g_ptr_array_index (array->elements, index_);
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_ARRAY (node))
+ return json_node_get_array (node) == NULL;
+
+ if (JSON_NODE_HOLDS_OBJECT (node))
+ return json_node_get_object (node) == NULL;
+
+ return FALSE;
}
/**