Replace the low-level json_writer API calls with the high-level json_print API to maintain consistency with the rest of the iproute2 codebase. Signed-off-by: Andrea Claudi --- misc/lnstat.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/misc/lnstat.c b/misc/lnstat.c index f802a0f3..8f359578 100644 --- a/misc/lnstat.c +++ b/misc/lnstat.c @@ -30,8 +30,9 @@ #include #include #include +#include -#include +#include "json_print.h" #include "lnstat.h" #include "version.h" @@ -109,21 +110,17 @@ static void print_line(FILE *of, const struct lnstat_file *lnstat_files, static void print_json(FILE *of, const struct lnstat_file *lnstat_files, const struct field_params *fp) { - json_writer_t *jw = jsonw_new(of); int i; - if (jw == NULL) { - fprintf(stderr, "Failed to create JSON writer\n"); - exit(1); - } - jsonw_start_object(jw); + new_json_obj_plain(1); + open_json_object(NULL); for (i = 0; i < fp->num; i++) { const struct lnstat_field *lf = fp->params[i].lf; - jsonw_uint_field(jw, lf->name, lf->result); + print_luint(PRINT_JSON, lf->name, NULL, lf->result); } - jsonw_end_object(jw); - jsonw_destroy(&jw); + close_json_object(); + delete_json_obj_plain(); } /* find lnstat_field according to user specification */ -- 2.51.0