Skip to content

JSON_GET_BOOL

Jurek Muszyński edited this page Mar 31, 2022 · 3 revisions

bool JSON_GET_BOOL(JSON *json, const char *name, bool *retval)

Description

Retrieves boolean value from JSON object.

Returns

TRUE if element has been found, otherwise FALSE.

Example

JSON json={0};

if ( !JSON_FROM_STRING(&json, some_string) )
    OUT("some_string is not a JSON");
else
{
    bool value;

    if ( !JSON_GET_BOOL(&json, "married", &value) )
        OUT("Couldn't get married");
    else
        OUT("<p>Married: %s</p>", value?"yes":"no");
}
Clone this wiki locally