summaryrefslogtreecommitdiff
path: root/rrdformat/rrdbinary/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'rrdformat/rrdbinary/types.go')
-rw-r--r--rrdformat/rrdbinary/types.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/rrdformat/rrdbinary/types.go b/rrdformat/rrdbinary/types.go
index 0bf4913..a6fa881 100644
--- a/rrdformat/rrdbinary/types.go
+++ b/rrdformat/rrdbinary/types.go
@@ -2,6 +2,7 @@ package rrdbinary
import (
"encoding/binary"
+ "encoding/json"
"math"
)
@@ -32,6 +33,15 @@ type EOF struct{} // 0 bytes
func (u Unival) AsUint64() uint64 { return uint64(u) }
func (u Unival) AsFloat64() float64 { return math.Float64frombits(uint64(u)) }
+// MarshalJSON is for my own debugging.
+func (f Float) MarshalJSON() ([]byte, error) {
+ raw := float64(f)
+ if math.IsNaN(raw) {
+ return json.Marshal("NaN")
+ }
+ return json.Marshal(raw)
+}
+
// Statically assert that each of the above types implements the
// 'unmarshaler' interface.
var _ unmarshaler = func() *String { return nil }()