Skip to content

JSON_PRESENT

Jurek Muszyński edited this page Dec 19, 2021 · 3 revisions

bool JSON_PRESENT(JSON *json, const char *name)

Description

Checks the field's presence in JSON object.

Returns

true if the field is present, otherwise false.

Example

JSON req={0};

if ( !REQ_DATA )
{
    OUT("<p>Payload is required.</p>");
    return false;
}

if ( !JSON_FROM_STRING(&req, REQ_DATA) )
{
    OUT("<p>Payload is not a valid JSON.</p>");
    return false;
}

if ( !JSON_PRESENT(&req, "description") )
{
    OUT("<p>Description is required in payload.</p>");
    return false;
}
Clone this wiki locally