From: Michael Tremer Date: Thu, 26 Jun 2025 13:11:22 +0000 (+0000) Subject: json: Add a function to add NULL to an object X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8fc1bfe02d1f203e74fdd257447053c8536adce9;p=pakfire.git json: Add a function to add NULL to an object Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/json.c b/src/pakfire/json.c index a2e73738..c0cda39f 100644 --- a/src/pakfire/json.c +++ b/src/pakfire/json.c @@ -151,6 +151,10 @@ int pakfire_json_new_object(struct json_object** json) { return 0; } +int pakfire_json_add_null(struct json_object* json, const char* name) { + return json_object_object_add(json, name, NULL); +} + int pakfire_json_add_string(struct json_object* json, const char* name, const char* value) { if (!value) diff --git a/src/pakfire/json.h b/src/pakfire/json.h index d4b7c36d..3f70ba6f 100644 --- a/src/pakfire/json.h +++ b/src/pakfire/json.h @@ -43,6 +43,7 @@ int pakfire_json_parse_from_file(struct json_object** json, char** error, const int pakfire_json_new_object(struct json_object** json); +int pakfire_json_add_null(struct json_object* json, const char* name); int pakfire_json_add_string(struct json_object* json, const char* name, const char* value); int pakfire_json_add_stringn(struct json_object* json, const char* name, const char* value, size_t length); int pakfire_json_add_stringf(struct json_object* json, const char* name, const char* format, ...)