UnmarshalJSON implements json.Unmarshaler.
(b []byte)
| 264 | |
| 265 | // UnmarshalJSON implements json.Unmarshaler. |
| 266 | func (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. |
| 283 | type String struct { |
nothing calls this directly
no test coverage detected