diff --git a/winpr/include/winpr/json.h b/winpr/include/winpr/json.h index 7e276c455..600b52a96 100644 --- a/winpr/include/winpr/json.h +++ b/winpr/include/winpr/json.h @@ -83,6 +83,8 @@ extern "C" WINPR_API WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* object, const char* name); WINPR_API WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* object, const char* name); + WINPR_API BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item); + WINPR_API char* WINPR_JSON_Print(WINPR_JSON* item); WINPR_API char* WINPR_JSON_PrintUnformatted(WINPR_JSON* item); diff --git a/winpr/libwinpr/utils/json/json.c b/winpr/libwinpr/utils/json/json.c index cffa62fb6..2249641e6 100644 --- a/winpr/libwinpr/utils/json/json.c +++ b/winpr/libwinpr/utils/json/json.c @@ -613,6 +613,22 @@ WINPR_JSON* WINPR_JSON_AddObjectToObject(WINPR_JSON* const object, const char* c #endif } +BOOL WINPR_JSON_AddItemToArray(WINPR_JSON* array, WINPR_JSON* item) +{ +#if defined(WITH_JSONC) + const int rc = json_object_array_add((json_object*)array, (json_object*)item); + if (rc != 0) + return FALSE; + return TRUE; +#elif defined(WITH_CJSON) + return cJSON_AddItemToArray((cJSON*)array, (cJSON*)item); +#else + WINPR_UNUSED(object); + WINPR_UNUSED(name); + return FALSE; +#endif +} + WINPR_JSON* WINPR_JSON_AddArrayToObject(WINPR_JSON* const object, const char* const name) { #if defined(WITH_JSONC)