jn2bool()
#
The function jn2bool
converts a JSON value to a boolean representation, interpreting various JSON types accordingly.
Prototype
BOOL jn2bool(json_t *jn_var);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
A pointer to a JSON value to be converted to a boolean. |
Return Value
Returns TRUE
if the JSON value represents a truthy value, otherwise returns FALSE
. Specifically, true
JSON values return TRUE
, false
and null
return FALSE
, numbers return TRUE
if nonzero, and strings return TRUE
if non-empty.
Notes
This function is useful for safely interpreting JSON values as boolean flags. It ensures that various JSON types are correctly mapped to boolean values.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples