Skip to content

Commit

Permalink
chore: use json.Unmarshal in favor of oj.ParseString
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Oct 29, 2024
1 parent 9f05b23 commit 5ba6558
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scrapers/processors/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (e Extract) Extract(ctx api.ScrapeContext, inputs ...v1.ScrapeResult) ([]v1
}
default:
opts := oj.Options{OmitNil: true, Sort: true, UseTags: true, FloatFormat: "%g"}
parsedConfig, err = oj.ParseString(oj.JSON(v, &opts))
err = json.Unmarshal([]byte(oj.JSON(v, &opts)), &parsedConfig)
if err != nil {
return results, fmt.Errorf("failed to parse json format=%s,%s): %v", input.Format, input.Source, err)
}
Expand All @@ -433,6 +433,7 @@ func (e Extract) Extract(ctx api.ScrapeContext, inputs ...v1.ScrapeResult) ([]v1
}
}

input.Config = parsedConfig
var ongoingInput v1.ScrapeResults = []v1.ScrapeResult{input}
if !input.BaseScraper.Transform.Script.IsEmpty() {
ctx.Logger.V(3).Infof("Applying script transformation")
Expand Down

0 comments on commit 5ba6558

Please sign in to comment.