From 8fc1bfe02d1f203e74fdd257447053c8536adce9 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 26 Jun 2025 13:11:22 +0000 Subject: [PATCH] json: Add a function to add NULL to an object Signed-off-by: Michael Tremer --- src/pakfire/json.c | 4 ++++ src/pakfire/json.h | 1 + 2 files changed, 5 insertions(+) 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, ...) -- 2.47.2