u/json: Add json getter

u_json_get() is much, much shorter than cJSON_GetObjectItemCaseSensitive().
This commit is contained in:
Christoph Haag 2020-04-23 20:01:05 +02:00 committed by Jakob Bornecrantz
parent e3b74c2e70
commit 74a328e909
2 changed files with 13 additions and 0 deletions

View file

@ -27,6 +27,12 @@ get(const cJSON *json, const char *f)
return cJSON_GetObjectItemCaseSensitive(json, f); return cJSON_GetObjectItemCaseSensitive(json, f);
} }
const cJSON *
u_json_get(const cJSON *json, const char *f)
{
return get(json, f);
}
bool bool
u_json_get_string_into_array(const cJSON *json, char *out_str, size_t max_size) u_json_get_string_into_array(const cJSON *json, char *out_str, size_t max_size)
{ {

View file

@ -20,6 +20,13 @@
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
/*!
* @brief Get a JSON object by string from a JSON object.
*
* @return The JSON object with the given name if successful, NULL if not.
*/
const cJSON *
u_json_get(const cJSON *json, const char *f);
/*! /*!
* @brief Parse a string from a JSON object into a char array. * @brief Parse a string from a JSON object into a char array.