@@ -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;
@@ -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;