From 036f7ab20b7bdcddcdbac4071e359602b1a0728f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 28 Jan 2020 08:58:49 -0500 Subject: wip xml --- rrdformat/rrdbinary/types.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'rrdformat/rrdbinary/types.go') 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 }() -- cgit v1.2.3