diff --git a/model/value.go b/model/value.go index 15a87570..f60675fa 100644 --- a/model/value.go +++ b/model/value.go @@ -98,11 +98,6 @@ func (s Sample) MarshalJSON() ([]byte, error) { return json.Marshal(&v) } -type sampleHistogramPairPtr struct { - Timestamp Time - Histogram *SampleHistogram -} - func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error { tmp := []interface{}{&s.Timestamp, &s.Histogram} wantLen := len(tmp) @@ -118,18 +113,18 @@ func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error { // UnmarshalJSON implements json.Unmarshaler. func (s *Sample) UnmarshalJSON(b []byte) error { v := struct { - Metric Metric `json:"metric"` - Value SamplePair `json:"value"` - Histogram sampleHistogramPairPtr `json:"histogram"` + Metric Metric `json:"metric"` + Value SamplePair `json:"value"` + Histogram *SampleHistogramPair `json:"histogram"` }{ Metric: s.Metric, Value: SamplePair{ Timestamp: s.Timestamp, Value: s.Value, }, - Histogram: sampleHistogramPairPtr{ + Histogram: &SampleHistogramPair{ Timestamp: s.Timestamp, - Histogram: s.Histogram, + Histogram: *s.Histogram, }, } @@ -138,9 +133,9 @@ func (s *Sample) UnmarshalJSON(b []byte) error { } s.Metric = v.Metric - if v.Histogram.Histogram != nil { + if v.Histogram != nil { s.Timestamp = v.Histogram.Timestamp - s.Histogram = v.Histogram.Histogram + s.Histogram = &v.Histogram.Histogram } else { s.Timestamp = v.Value.Timestamp s.Value = v.Value.Value