@@ -151,16 +151,16 @@ func (j *jsonStage) processEntry(extracted map[string]any, entry *string) error
151151 }
152152 continue
153153 }
154- value , err := j .simplifyType (rawResult )
155- if err == nil {
154+ value , ok := j .simplifyType (rawResult )
155+ if ok {
156156 extracted [name ] = value
157157 }
158158 }
159159 if j .regex .String () != "" {
160160 for key , rawValue := range data {
161161 if j .regex .MatchString (key ) {
162- value , err := j .simplifyType (rawValue )
163- if err == nil {
162+ value , ok := j .simplifyType (rawValue )
163+ if ok {
164164 extracted [key ] = value
165165 }
166166 }
@@ -172,28 +172,28 @@ func (j *jsonStage) processEntry(extracted map[string]any, entry *string) error
172172 return nil
173173}
174174
175- // extractWithType returns the value if it's a simple type (string, number, bool),
176- // otherwise, it returns it as a JSON string
177- func (j * jsonStage ) simplifyType (value any ) (any , error ) {
175+ // simplifyType returns the value if it's a simple type (string, number, bool),
176+ // otherwise, it returns it as a JSON string. If unsuccessful, the second return value is false.
177+ func (j * jsonStage ) simplifyType (value any ) (any , bool ) {
178178 switch value .(type ) {
179179 case float64 :
180- return value , nil
180+ return value , true
181181 case string :
182- return value , nil
182+ return value , true
183183 case bool :
184- return value , nil
184+ return value , true
185185 case nil :
186- return nil , nil
186+ return nil , true
187187 default :
188188 // If the value wasn't a string or a number, marshal it back to json
189189 jm , err := json .Marshal (value )
190190 if err != nil {
191191 if Debug {
192192 level .Debug (j .logger ).Log ("msg" , "failed to marshal complex type back to string" , "err" , err )
193- return nil , err
193+ return nil , false
194194 }
195195 }
196- return string (jm ), nil
196+ return string (jm ), true
197197 }
198198}
199199
0 commit comments