From 20d67b7636cf9a197401e701def3d41459447a9c Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Fri, 29 Dec 2023 16:37:40 +0100 Subject: [PATCH] use select based on body type --- pkg/request/request.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/request/request.go b/pkg/request/request.go index 6d0f0cc43..c2783959e 100644 --- a/pkg/request/request.go +++ b/pkg/request/request.go @@ -963,7 +963,12 @@ func (r *RequestHandler) ProcessResponse(resp *c8y.Response, respError error, in if len(commonOptions.Filters.Pluck) == 0 || (len(commonOptions.Filters.Pluck) == 1 && commonOptions.Filters.Pluck[0] == "**") { r.Console.SetHeaderFromInput(strings.Join(body.Keys(), ",")) } - if filterOutput, filterErr := commonOptions.Filters.ApplyToData(body.Data, ".[]", false, r.Console.SetHeaderFromInput); filterErr != nil { + + jqSelect := "." + if body.IsArray() { + jqSelect = ".[]" + } + if filterOutput, filterErr := commonOptions.Filters.ApplyToData(body.Data, jqSelect, false, r.Console.SetHeaderFromInput); filterErr != nil { r.Logger.Warnf("filter error. %s", filterErr) responseText = filterOutput } else {