From: Michael Tremer Date: Sat, 21 Jun 2025 15:57:39 +0000 (+0000) Subject: json: Use the new string serialization function everywhere X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=619c0e0d153c82535103ae61d29e349190033650;p=pakfire.git json: Use the new string serialization function everywhere Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/dump.c b/src/cli/lib/dump.c index 80640ca1..2f39b6d5 100644 --- a/src/cli/lib/dump.c +++ b/src/cli/lib/dump.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -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); diff --git a/src/pakfire/archive.c b/src/pakfire/archive.c index 588d83f8..438b3f3d 100644 --- a/src/pakfire/archive.c +++ b/src/pakfire/archive.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/src/pakfire/daemon.c b/src/pakfire/daemon.c index 303f7f29..2b562d5a 100644 --- a/src/pakfire/daemon.c +++ b/src/pakfire/daemon.c @@ -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; } diff --git a/src/pakfire/json.c b/src/pakfire/json.c index a7531590..0eee8228 100644 --- a/src/pakfire/json.c +++ b/src/pakfire/json.c @@ -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) diff --git a/src/pakfire/oci.c b/src/pakfire/oci.c index cf356bde..d9a086d4 100644 --- a/src/pakfire/oci.c +++ b/src/pakfire/oci.c @@ -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;