]> git.ipfire.org Git - pakfire.git/commitdiff
json: Use the new string serialization function everywhere
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Jun 2025 15:57:39 +0000 (15:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Jun 2025 15:57:39 +0000 (15:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/dump.c
src/pakfire/archive.c
src/pakfire/daemon.c
src/pakfire/json.c
src/pakfire/oci.c

index 80640ca15fde7d21e9afb14dd952b0693ada9934..2f39b6d5f1ef1d21f21b6828f9921238361ef780 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <json.h>
 
+#include <pakfire/json.h>
 #include <pakfire/package.h>
 #include <pakfire/packagelist.h>
 #include <pakfire/pakfire.h>
@@ -101,8 +102,7 @@ int cli_dump_json(struct json_object* object) {
        int r;
 
        // Serialize the object as a JSON string
-       const char* buffer = json_object_to_json_string_ext(object,
-               JSON_C_TO_STRING_PRETTY|JSON_C_TO_STRING_PRETTY_TAB);
+       const char* buffer = pakfire_json_to_string(object);
 
        // Print to the console
        r = printf("%s\n", buffer);
index 588d83f822f8c14673f3e3606a40200948de018e..438b3f3db80fec7fb9197424c77e4aed6be15dee 100644 (file)
@@ -44,6 +44,7 @@
 #include <pakfire/hex.h>
 #include <pakfire/i18n.h>
 #include <pakfire/jail.h>
+#include <pakfire/json.h>
 #include <pakfire/linter.h>
 #include <pakfire/logging.h>
 #include <pakfire/package.h>
@@ -482,8 +483,7 @@ static int pakfire_archive_parse_json_metadata(struct pakfire_archive* archive,
        }
 
        DEBUG(archive->ctx, "Successfully parsed package metadata:\n%s\n",
-               json_object_to_json_string_ext(archive->metadata,
-                       JSON_C_TO_STRING_PRETTY|JSON_C_TO_STRING_PRETTY_TAB));
+               pakfire_json_to_string(archive->metadata));
 
        // Success
        r = 0;
index 303f7f29a2d2dd94582efd151b25cc69d43494c0..2b562d5a3ef385bd11f48cc62f1b3ffe9bbb04cd 100644 (file)
@@ -584,8 +584,7 @@ static int pakfire_daemon_recv(struct pakfire_xfer* xfer,
                        goto ERROR;
 
        } else {
-               ERROR(daemon->ctx, "Unknown message. Ignoring:\n%s\n",
-                       json_object_to_json_string_ext(m, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY));
+               ERROR(daemon->ctx, "Unknown message. Ignoring:\n%s\n", pakfire_json_to_string(m));
 
                r = 0;
        }
index a753159013c75789cdbede85c0613af7d1afb7ce..0eee8228d4e49e2a4b9f93520c453493fc261f74 100644 (file)
@@ -54,10 +54,7 @@ struct json_object* pakfire_json_parse(
        }
 
        // Log what we have parsed
-       DEBUG(ctx, "Parsed JSON:\n%s\n",
-               json_object_to_json_string_ext(json,
-                       JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY)
-       );
+       DEBUG(ctx, "Parsed JSON:\n%s\n", pakfire_json_to_string(json));
 
 ERROR:
        if (tokener)
index cf356bde0e8b107ebf8caeab5a304c5c63218eac..d9a086d4f8cae17ae3a5d9657c670eb3466ccf06 100644 (file)
@@ -114,7 +114,7 @@ static int pakfire_oci_writer_write_json_blob(
        int r;
 
        // Serialize the JSON object
-       buffer = json_object_to_json_string_ext(json, 0);
+       buffer = pakfire_json_to_string(json);
        if (!buffer) {
                r = -errno;
                goto ERROR;