mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
u/json: Add bool getter function
This commit is contained in:
parent
b5dd07f2fa
commit
f47c384b79
1
doc/changes/aux/mr.266.2.md
Normal file
1
doc/changes/aux/mr.266.2.md
Normal file
|
@ -0,0 +1 @@
|
|||
u/json: Add bool getter function.
|
|
@ -46,6 +46,23 @@ u_json_get_string_into_array(const cJSON *json, char *out_str, size_t max_size)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
u_json_get_bool(const cJSON *json, bool *out_bool)
|
||||
{
|
||||
assert(out_bool != NULL);
|
||||
|
||||
if (!json) {
|
||||
return false;
|
||||
}
|
||||
if (!cJSON_IsBool(json)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_bool = json->valueint;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
u_json_get_int(const cJSON *json, int *out_int)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,14 @@ extern "C" {
|
|||
bool
|
||||
u_json_get_string_into_array(const cJSON *json, char *out, size_t max_size);
|
||||
|
||||
/*!
|
||||
* @brief Parse an bool from a JSON object.
|
||||
*
|
||||
* @return true if successful, false if not.
|
||||
*/
|
||||
bool
|
||||
u_json_get_bool(const cJSON *json, bool *out_bool);
|
||||
|
||||
/*!
|
||||
* @brief Parse an int from a JSON object.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue