Skip to content

Commit 7f2fef3

Browse files
committed
Fix filter=count output to avoid empty objects (#197)
1 parent 17afc27 commit 7f2fef3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/output.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,19 @@ func filterResponse(response map[string]interface{}, filter []string, excludeFil
278278
}
279279
}
280280

281+
// Skip completely empty rows after filtering
282+
if len(filteredRow) == 0 {
283+
continue
284+
}
285+
281286
filteredRows = append(filteredRows, filteredRow)
282287
}
288+
289+
// If no non-empty rows remain for this key, omit the key entirely
290+
if len(filteredRows) == 0 {
291+
continue
292+
}
293+
283294
if originalKind == reflect.Map && len(filteredRows) > 0 {
284295
filteredResponse[key] = filteredRows[0]
285296
} else {

0 commit comments

Comments
 (0)