From 182892da124533806ea6b3833afd22717410a06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Wed, 1 Apr 2026 17:53:39 +0200 Subject: [PATCH] hyptop: Adapt to new JSON Lines text format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit util_fmt now provides support for JSON Lines text format. Adapt certain checks in the code and document the newly supported format in the man page accordingly. Signed-off-by: Jan Höppner --- hyptop/hyptop.8 | 19 +++++++++++++++++++ hyptop/hyptop.c | 2 +- hyptop/table.c | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/hyptop/hyptop.8 b/hyptop/hyptop.8 index 75e63dd6..c36113e6 100644 --- a/hyptop/hyptop.8 +++ b/hyptop/hyptop.8 @@ -96,6 +96,17 @@ with an ASCII Record Separator character (0x1e) and suffixed with an ASCII Line Feed character (0x0a) in accordance with RFC7464. .BR +See section "OUTPUT FORMAT" for more details. +.BR +.PP +.IP \(bu 3 +.B jsonl: +Line-delimited JSON data structures + +Data for each iteration is formatted as a separate JSON data structure +separated by ASCII Line Feed character (0x0a, LF). +.BR + See section "OUTPUT FORMAT" for more details. .BR .PP @@ -458,6 +469,14 @@ Subsequent objects each represent performance data for one iteration .br .PP +.SS jsonl + +The jsonl output format is a data streaming variation of the JSON output format +described above with the same properties as the json\-seq output with the +difference that JSON data is separated only by an ASCII Line Feed character +(0x0a, LF). + + .SH EXAMPLES To start hyptop with the "sys_list" window in interactive mode, enter: .br diff --git a/hyptop/hyptop.c b/hyptop/hyptop.c index 7b909588..b28e0c36 100644 --- a/hyptop/hyptop.c +++ b/hyptop/hyptop.c @@ -233,7 +233,7 @@ static void l_fmt_init(void) flags |= FMT_QUOTEALL; if (g.o.format == FMT_CSV || g.o.format_all) flags |= FMT_KEEPINVAL; - if (g.o.format == FMT_JSON || g.o.format == FMT_JSONSEQ) + if (util_fmt_is_json(g.o.format)) flags |= FMT_HANDLEINT; util_fmt_init(stdout, g.o.format, flags, 1); } diff --git a/hyptop/table.c b/hyptop/table.c index 554099a4..57cf0f3b 100644 --- a/hyptop/table.c +++ b/hyptop/table.c @@ -1037,7 +1037,7 @@ void table_fmt_start(void) { if (!g.o.format_specified) return; - if (g.o.format != FMT_JSONSEQ) + if (!util_fmt_is_json_stream(g.o.format)) util_fmt_obj_start(FMT_LIST, "hyptop"); } @@ -1045,7 +1045,7 @@ void table_fmt_end(void) { if (!g.o.format_specified) return; - if (g.o.format != FMT_JSONSEQ) + if (!util_fmt_is_json_stream(g.o.format)) util_fmt_obj_end(); /* hyptop[] */ }