Skip to content

Commit

Permalink
Jq: add quote option (evcc-io#18009)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored and jonilala796 committed Jan 3, 2025
1 parent 40d5f84 commit a3ca4e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions provider/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ type Pipeline struct {
re *regexp.Regexp
jq *gojq.Query
allowEmpty bool
quote bool
dflt string
unpack string
decode string
}

type Settings struct {
AllowEmpty bool
Quote bool
Regex string
Default string
Jq string
Expand All @@ -39,6 +41,7 @@ func New(log *util.Logger, cc Settings) (*Pipeline, error) {
p := &Pipeline{
log: log,
allowEmpty: cc.AllowEmpty,
quote: cc.Quote,
}

var err error
Expand Down Expand Up @@ -191,6 +194,9 @@ func (p *Pipeline) Process(in []byte) ([]byte, error) {
}

if p.jq != nil {
if p.quote {
b = []byte(fmt.Sprintf("%q", string(b)))
}
v, err := jq.Query(p.jq, b)
if err != nil {
return b, backoff.Permanent(err)
Expand Down

0 comments on commit a3ca4e2

Please sign in to comment.