From 7b275b1aeb69f01b6dabaaae015c58a11bfe6b8a Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Tue, 29 Oct 2024 18:47:41 +0530 Subject: [PATCH] chore: use json.Unmarshal in favor of oj.ParseString --- scrapers/processors/json.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scrapers/processors/json.go b/scrapers/processors/json.go index 88c0dbfb..908bfebb 100644 --- a/scrapers/processors/json.go +++ b/scrapers/processors/json.go @@ -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) } @@ -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")