UnmarshalJSON implements json.Unmarshaler.
(b []byte)
| 39 | |
| 40 | // UnmarshalJSON implements json.Unmarshaler. |
| 41 | func (v *SampleValue) UnmarshalJSON(b []byte) error { |
| 42 | if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { |
| 43 | return errors.New("sample value must be a quoted string") |
| 44 | } |
| 45 | f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | *v = SampleValue(f) |
| 50 | return nil |
| 51 | } |
| 52 | |
| 53 | // Equal returns true if the value of v and o is equal or if both are NaN. Note |
| 54 | // that v==o is false if both are NaN. If you want the conventional float |
nothing calls this directly
no test coverage detected