aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qobject/json-parser.c2
-rw-r--r--tests/check-qjson.c15
2 files changed, 15 insertions, 2 deletions
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 4288267bd3..717cb8fde7 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -561,6 +561,8 @@ static QObject *parse_keyword(JSONParserContext *ctxt)
ret = QOBJECT(qbool_from_int(true));
} else if (token_is_keyword(token, "false")) {
ret = QOBJECT(qbool_from_int(false));
+ } else if (token_is_keyword(token, "null")) {
+ ret = qnull();
} else {
parse_error(ctxt, token, "invalid keyword `%s'", token_get_value(token));
goto out;
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 95497a037e..60e5b22a98 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1,6 +1,6 @@
/*
* Copyright IBM, Corp. 2009
- * Copyright (c) 2013 Red Hat Inc.
+ * Copyright (c) 2013, 2015 Red Hat Inc.
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
@@ -1005,6 +1005,7 @@ static void keyword_literal(void)
{
QObject *obj;
QBool *qbool;
+ QObject *null;
QString *str;
obj = qobject_from_json("true");
@@ -1041,7 +1042,7 @@ static void keyword_literal(void)
g_assert(qbool_get_int(qbool) == 0);
QDECREF(qbool);
-
+
obj = qobject_from_jsonf("%i", true);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
@@ -1050,6 +1051,16 @@ static void keyword_literal(void)
g_assert(qbool_get_int(qbool) != 0);
QDECREF(qbool);
+
+ obj = qobject_from_json("null");
+ g_assert(obj != NULL);
+ g_assert(qobject_type(obj) == QTYPE_QNULL);
+
+ null = qnull();
+ g_assert(null == obj);
+
+ qobject_decref(obj);
+ qobject_decref(null);
}
typedef struct LiteralQDictEntry LiteralQDictEntry;