Skip to content

Commit

Permalink
Add json_boolean_value as alias for json_is_true
Browse files Browse the repository at this point in the history
Fixes #146.
  • Loading branch information
akheron committed Dec 4, 2013
1 parent 34d8b92 commit 05f7d30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/apiref.rst
Expand Up @@ -150,6 +150,11 @@ functions:
Returns true for types ``JSON_TRUE`` and ``JSON_FALSE``, and false
for values of other types and for *NULL*.

.. function:: json_boolean_value(const json_t *json)

Alias of :func:`json_is_true()`, i.e. returns 1 for ``JSON_TRUE``
and 0 otherwise.


.. _apiref-reference-count:

Expand Down
1 change: 1 addition & 0 deletions src/jansson.h
Expand Up @@ -75,6 +75,7 @@ typedef long json_int_t;
#define json_is_number(json) (json_is_integer(json) || json_is_real(json))
#define json_is_true(json) ((json) && json_typeof(json) == JSON_TRUE)
#define json_is_false(json) ((json) && json_typeof(json) == JSON_FALSE)
#define json_boolean_value json_is_true
#define json_is_boolean(json) (json_is_true(json) || json_is_false(json))
#define json_is_null(json) ((json) && json_typeof(json) == JSON_NULL)

Expand Down
2 changes: 2 additions & 0 deletions test/suites/api/test_simple.c
Expand Up @@ -27,6 +27,8 @@ static void run_tests()
value = json_boolean(0);
if(!json_is_false(value))
fail("json_boolean(0) failed");
if(json_boolean_value(value) != 0)
fail("json_boolean_value failed");
json_decref(value);


Expand Down

0 comments on commit 05f7d30

Please sign in to comment.