@@ -98,11 +98,6 @@ func (s Sample) MarshalJSON() ([]byte, error) {
98
98
return json .Marshal (& v )
99
99
}
100
100
101
- type sampleHistogramPairPtr struct {
102
- Timestamp Time
103
- Histogram * SampleHistogram
104
- }
105
-
106
101
func (s * sampleHistogramPairPtr ) UnmarshalJSON (buf []byte ) error {
107
102
tmp := []interface {}{& s .Timestamp , & s .Histogram }
108
103
wantLen := len (tmp )
@@ -118,18 +113,18 @@ func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error {
118
113
// UnmarshalJSON implements json.Unmarshaler.
119
114
func (s * Sample ) UnmarshalJSON (b []byte ) error {
120
115
v := struct {
121
- Metric Metric `json:"metric"`
122
- Value SamplePair `json:"value"`
123
- Histogram sampleHistogramPairPtr `json:"histogram"`
116
+ Metric Metric `json:"metric"`
117
+ Value SamplePair `json:"value"`
118
+ Histogram * SampleHistogramPair `json:"histogram"`
124
119
}{
125
120
Metric : s .Metric ,
126
121
Value : SamplePair {
127
122
Timestamp : s .Timestamp ,
128
123
Value : s .Value ,
129
124
},
130
- Histogram : sampleHistogramPairPtr {
125
+ Histogram : & SampleHistogramPair {
131
126
Timestamp : s .Timestamp ,
132
- Histogram : s .Histogram ,
127
+ Histogram : * s .Histogram ,
133
128
},
134
129
}
135
130
@@ -138,9 +133,9 @@ func (s *Sample) UnmarshalJSON(b []byte) error {
138
133
}
139
134
140
135
s .Metric = v .Metric
141
- if v .Histogram . Histogram != nil {
136
+ if v .Histogram != nil {
142
137
s .Timestamp = v .Histogram .Timestamp
143
- s .Histogram = v .Histogram .Histogram
138
+ s .Histogram = & v .Histogram .Histogram
144
139
} else {
145
140
s .Timestamp = v .Value .Timestamp
146
141
s .Value = v .Value .Value
0 commit comments