From 9dfb5000cad954431165e836e203e561ccb79c66 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 27 Oct 2012 11:48:58 +0100 Subject: 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. --- json-glib/json-object.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'json-glib/json-object.c') 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; } /** -- cgit v1.2.1