Jq: add quote option (#18009)
This commit is contained in:
parent
ff5ad907b9
commit
9f2a9ab162
1 changed files with 6 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ type Pipeline struct {
|
|||
re *regexp.Regexp
|
||||
jq *gojq.Query
|
||||
allowEmpty bool
|
||||
quote bool
|
||||
dflt string
|
||||
unpack string
|
||||
decode string
|
||||
|
|
@ -28,6 +29,7 @@ type Pipeline struct {
|
|||
|
||||
type Settings struct {
|
||||
AllowEmpty bool
|
||||
Quote bool
|
||||
Regex string
|
||||
Default string
|
||||
Jq string
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue