mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[winpr,json] fix json-c case insensitive object get
This commit is contained in:
@@ -119,14 +119,14 @@ extern "C"
|
||||
/**
|
||||
* @brief Return a pointer to an JSON object item
|
||||
* @param object the JSON object
|
||||
* @param string the name of the object
|
||||
* @param string the name of the object (case is ignored)
|
||||
* @return A pointer to the object identified by @ref string or \b NULL
|
||||
* @since version 3.6.0
|
||||
*/
|
||||
WINPR_API WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string);
|
||||
|
||||
/**
|
||||
* @brief Same as @ref WINPR_JSON_GetObjectItem but with case insensitive matching
|
||||
* @brief Same as @ref WINPR_JSON_GetObjectItem but with case sensitive matching
|
||||
*
|
||||
* @param object the JSON instance to query
|
||||
* @param string the name of the object
|
||||
|
||||
@@ -184,7 +184,18 @@ size_t WINPR_JSON_GetArraySize(const WINPR_JSON* array)
|
||||
WINPR_JSON* WINPR_JSON_GetObjectItem(const WINPR_JSON* object, const char* string)
|
||||
{
|
||||
#if defined(WITH_JSONC)
|
||||
return json_object_object_get((const json_object*)object, string);
|
||||
struct json_object_iterator it = json_object_iter_begin((const json_object*)object);
|
||||
struct json_object_iterator itEnd = json_object_iter_end((const json_object*)object);
|
||||
while (!json_object_iter_equal(&it, &itEnd))
|
||||
{
|
||||
const char* key = json_object_iter_peek_name(&it);
|
||||
if (_stricmp(key, string) == 0)
|
||||
{
|
||||
return json_object_iter_peek_value(&it);
|
||||
}
|
||||
json_object_iter_next(&it);
|
||||
}
|
||||
return NULL;
|
||||
#elif defined(WITH_CJSON)
|
||||
return cJSON_GetObjectItem((const cJSON*)object, string);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user