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

Method UnmarshalJSON

model/value.go:265–279  ·  view source on GitHub ↗

UnmarshalJSON implements json.Unmarshaler.

(b []byte)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

SampleValueTypeAlias · 0.85

Tested by

no test coverage detected