Skip to content

Commit

Permalink
fix: bump github.com/tidwall/gjson from 1.10.2 to 1.14.1 (#11264)
Browse files Browse the repository at this point in the history
* Bump github.com/tidwall/gjson from v1.10.2 to v1.14.1

* Fix node references which are switched to parent relative now.
  • Loading branch information
srebhan authored Jun 7, 2022
1 parent 34eff49 commit 5da99fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ require (
github.com/stretchr/testify v1.7.1
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
github.com/testcontainers/testcontainers-go v0.12.0
github.com/tidwall/gjson v1.10.2
github.com/tidwall/gjson v1.14.1
github.com/tinylib/msgp v1.1.6
github.com/vapourismo/knx-go v0.0.0-20211128234507-8198fa17db36
github.com/vjeantet/grok v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2176,8 +2176,8 @@ github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955u
github.com/testcontainers/testcontainers-go v0.12.0 h1:SK0NryGHIx7aifF6YqReORL18aGAA4bsDPtikDVCEyg=
github.com/testcontainers/testcontainers-go v0.12.0/go.mod h1:SIndOQXZng0IW8iWU1Js0ynrfZ8xcxrTtDfF6rD2pxs=
github.com/tetafro/godot v1.4.4/go.mod h1:FVDd4JuKliW3UgjswZfJfHq4vAx0bD/Jd5brJjGeaz4=
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
16 changes: 11 additions & 5 deletions plugins/parsers/json_v2/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ func (p *Parser) processMetric(input []byte, data []DataSet, tag bool, timestamp
map[string]interface{}{},
timestamp,
),
Result: result,
Result: result,
ParentIndex: result.Index,
}

// Expand all array's and nested arrays into separate metrics
Expand Down Expand Up @@ -296,9 +297,10 @@ func (p *Parser) expandArray(result MetricNode, timestamp time.Time) ([]telegraf
)
if val.IsObject() {
n := result
n.ParentIndex += val.Index
n.Metric = m
n.Result = val
n.Index = val.Index - result.Index
n.ParentIndex = n.Index + result.ParentIndex
r, err := p.combineObject(n, timestamp)
if err != nil {
return false
Expand All @@ -315,9 +317,10 @@ func (p *Parser) expandArray(result MetricNode, timestamp time.Time) ([]telegraf

mergeMetric(result.Metric, m)
n := result
n.ParentIndex += val.Index
n.Metric = m
n.Result = val
n.Index = val.Index - result.Index
n.ParentIndex = n.Index + result.ParentIndex
r, err := p.expandArray(n, timestamp)
if err != nil {
return false
Expand Down Expand Up @@ -454,15 +457,16 @@ func (p *Parser) processObjects(input []byte, objects []JSONObject, timestamp ti
}

rootObject := MetricNode{
ParentIndex: 0,
Metric: metric.New(
p.measurementName,
map[string]string{},
map[string]interface{}{},
timestamp,
),
Result: result,
Result: result,
ParentIndex: 0,
}

metrics, err := p.expandArray(rootObject, timestamp)
if err != nil {
return nil, err
Expand Down Expand Up @@ -534,6 +538,8 @@ func (p *Parser) combineObject(result MetricNode, timestamp time.Time) ([]telegr
return false
}
} else {
arrayNode.Index -= result.Index
arrayNode.ParentIndex -= result.Index
r, err := p.expandArray(arrayNode, timestamp)
if err != nil {
return false
Expand Down

0 comments on commit 5da99fa

Please sign in to comment.