Skip to content

Commit

Permalink
use select based on body type
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Dec 29, 2023
1 parent 43172de commit 20d67b7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20d67b7

Please sign in to comment.