diff options
author | Petri Lehtinen <petri@digip.org> | 2013-12-04 09:14:17 +0200 |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2013-12-04 09:14:19 +0200 |
commit | 05f7d30e5a49e00bc0438b1a76103e27464500a7 (patch) | |
tree | ec415ed456ed27a9f857b3adbb41743d5f8cfe1b | |
parent | 34d8b92dcecb6dd79fbc0ae878ca3ae7cef07afb (diff) | |
download | jansson-05f7d30e5a49e00bc0438b1a76103e27464500a7.zip jansson-05f7d30e5a49e00bc0438b1a76103e27464500a7.tar.gz jansson-05f7d30e5a49e00bc0438b1a76103e27464500a7.tar.bz2 |
Add json_boolean_value as alias for json_is_true
Fixes #146.
-rw-r--r-- | doc/apiref.rst | 5 | ||||
-rw-r--r-- | src/jansson.h | 1 | ||||
-rw-r--r-- | test/suites/api/test_simple.c | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/doc/apiref.rst b/doc/apiref.rst index 13b7901..717e140 100644 --- a/doc/apiref.rst +++ b/doc/apiref.rst @@ -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: diff --git a/src/jansson.h b/src/jansson.h index 27c0c74..c497598 100644 --- a/src/jansson.h +++ b/src/jansson.h @@ -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) diff --git a/test/suites/api/test_simple.c b/test/suites/api/test_simple.c index ca97a7d..7eed591 100644 --- a/test/suites/api/test_simple.c +++ b/test/suites/api/test_simple.c @@ -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); |