mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[winpr,json] add WINPR_JSON_AddIntegerToObject
This function adds a integer value (in contrast to real values with WINPR_JSON_AddNumberToObject) to a JSON object.
This commit is contained in:
@@ -346,6 +346,16 @@ extern "C"
|
||||
WINPR_API WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name,
|
||||
double number);
|
||||
|
||||
/**
|
||||
* @brief WINPR_JSON_AddIntegerToObject
|
||||
* @param object The JSON object the new item is added to
|
||||
* @param name The name of the object
|
||||
* @return the new JSON item added
|
||||
* @since version 3.6.0
|
||||
*/
|
||||
WINPR_API WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name,
|
||||
int64_t number);
|
||||
|
||||
/**
|
||||
* @brief WINPR_JSON_AddStringToObject
|
||||
* @param object The JSON object the new item is added to
|
||||
|
||||
@@ -259,6 +259,13 @@ WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, d
|
||||
return cJSON_AddNumberToObject((cJSON*)object, name, number);
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name, int64_t number)
|
||||
{
|
||||
char str[64] = { 0 };
|
||||
(void)_snprintf(str, sizeof(str), "%" PRId64, number);
|
||||
return cJSON_AddRawToObject((cJSON*)object, name, str);
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, const char* string)
|
||||
{
|
||||
return cJSON_AddStringToObject((cJSON*)object, name, string);
|
||||
|
||||
@@ -298,6 +298,12 @@ WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, d
|
||||
return add_to_object(object, name, obj);
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name, int64_t number)
|
||||
{
|
||||
json_t* obj = json_integer(number);
|
||||
return add_to_object(object, name, obj);
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, const char* string)
|
||||
{
|
||||
json_t* obj = json_string(string);
|
||||
|
||||
@@ -274,6 +274,17 @@ WINPR_JSON* WINPR_JSON_AddNumberToObject(WINPR_JSON* object, const char* name, d
|
||||
return obj;
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddIntegerToObject(WINPR_JSON* object, const char* name, int64_t number)
|
||||
{
|
||||
struct json_object* obj = json_object_new_int64(number);
|
||||
if (json_object_object_add((json_object*)object, name, obj) != 0)
|
||||
{
|
||||
json_object_put(obj);
|
||||
return NULL;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
WINPR_JSON* WINPR_JSON_AddStringToObject(WINPR_JSON* object, const char* name, const char* string)
|
||||
{
|
||||
struct json_object* obj = json_object_new_string(string);
|
||||
|
||||
Reference in New Issue
Block a user