Skip to content

JSON_GET_BOOL_A

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

bool JSON_GET_BOOL_A(JSON *json, int index, bool *retval)

Description

Retrieves boolean value from JSON array.

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;

    for ( int i=0; i<JSON_COUNT(&json); ++i )
    {
        if ( !JSON_GET_BOOL_A(&json, i, &value) )
            OUT("Couldn't get i-th element from the array");
        else
            OUT("<p>Married: %s</p>", value?"yes":"no");
    }
}

Clone this wiki locally