From 527f85f8e65a99e77a61279928744822cddd2757 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 24 Nov 2017 10:55:13 +0000 Subject: [PATCH] Implement both JsonMarshaler and JsonUnmarshaler If a type only defines one-half of the symmetry (e.g. it implements MarshalJSON() but not UnmarshalJSON() ), then that type doesn't satisfy the codec encoding/decoding check and instead codec will not encode or decode the item using the special interface methods. --- util/data/data.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/data/data.go b/util/data/data.go index 9702e21d..652839a9 100644 --- a/util/data/data.go +++ b/util/data/data.go @@ -77,6 +77,10 @@ func (d *Doc) MarshalJSON() ([]byte, error) { return json.Marshal(d.Data()) } +func (d *Doc) UnmarshalJSON(data []byte) error { + return json.Unmarshal(data, &d.data) +} + // -------------------------------------------------------------------------------- func (d *Doc) path(path ...string) (paths []string) {