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