True, False and Null
====================
-These values are implemented as singletons, so each of these functions
-returns the same value each time.
+These three values are implemented as singletons, so the returned
+pointers won't change between invocations of these functions.
.. function:: json_t *json_true(void)
Returns the JSON false value.
+.. function:: json_t *json_boolean(val)
+
+ .. refcounting:: new
+
+ Returns JSON false if ``val`` is zero, and JSON true otherwise.
+ This is a macro, and equivalent to ``val ? json_true() :
+ json_false()``.
+
+
.. function:: json_t *json_null(void)
.. refcounting:: new
json_t *json_real(double value);
json_t *json_true(void);
json_t *json_false(void);
+#define json_boolean(val) ((val) ? json_true() : json_false())
json_t *json_null(void);
static JSON_INLINE
{
json_t *value;
+ value = json_boolean(1);
+ if(!json_is_true(value))
+ fail("json_boolean(1) failed");
+ json_decref(value);
+
+ value = json_boolean(-123);
+ if(!json_is_true(value))
+ fail("json_boolean(-123) failed");
+ json_decref(value);
+
+ value = json_boolean(0);
+ if(!json_is_false(value))
+ fail("json_boolean(0) failed");
+ json_decref(value);
+
+
value = json_integer(1);
if(json_typeof(value) != JSON_INTEGER)
fail("json_typeof failed");