From 7f2fef3944784c5227444513912e17cd390aa5c3 Mon Sep 17 00:00:00 2001 From: dheeraj12347 Date: Thu, 26 Mar 2026 06:37:06 +0000 Subject: [PATCH] Fix filter=count output to avoid empty objects (#197) --- cmd/output.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/output.go b/cmd/output.go index 79f3900..434b644 100644 --- a/cmd/output.go +++ b/cmd/output.go @@ -278,8 +278,19 @@ func filterResponse(response map[string]interface{}, filter []string, excludeFil } } + // Skip completely empty rows after filtering + if len(filteredRow) == 0 { + continue + } + filteredRows = append(filteredRows, filteredRow) } + + // If no non-empty rows remain for this key, omit the key entirely + if len(filteredRows) == 0 { + continue + } + if originalKind == reflect.Map && len(filteredRows) > 0 { filteredResponse[key] = filteredRows[0] } else {