Skip to content

JSON_GET_STR

Jurek Muszyński edited this page Sep 11, 2018 · 4 revisions

char *JSON_GET_STR(JSON json, const char *name)

Description

Retrieves string value from JSON object. If name is of different type (i.e. integer) then string representation will be returned.

Returns

Pointer to the string. If the element of required name doesn't exist, empty string is returned.

Example

OUT("<p>Name: %s</p>", JSON_GET_STR(json, "name"));
// if "age" is of type integer, both will work:
OUT("<p>Age: %d</p>", JSON_GET_INT(json, "age"));
OUT("<p>Age: %s</p>", JSON_GET_STR(json, "age"));
Clone this wiki locally