MCPcopy Create free account
hub / github.com/prometheus/common / UnmarshalJSON

Method UnmarshalJSON

model/value.go:266–280  ·  view source on GitHub ↗

UnmarshalJSON implements json.Unmarshaler.

(b []byte)

Source from the content-addressed store, hash-verified

264
265// UnmarshalJSON implements json.Unmarshaler.
266func (s *Scalar) UnmarshalJSON(b []byte) error {
267 var f string
268 v := [...]any{&s.Timestamp, &f}
269
270 if err := json.Unmarshal(b, &v); err != nil {
271 return err
272 }
273
274 value, err := strconv.ParseFloat(f, 64)
275 if err != nil {
276 return fmt.Errorf("error parsing sample value: %w", err)
277 }
278 s.Value = SampleValue(value)
279 return nil
280}
281
282// String is a string value evaluated at the set timestamp.
283type String struct {

Callers

nothing calls this directly

Calls 1

SampleValueTypeAlias · 0.85

Tested by

no test coverage detected