From 969179660b3bfc0b0a7c13801da4321556d71ae8 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 20 Feb 2017 09:46:26 +0000 Subject: [PATCH] Enable data docs to self encode to JSON --- util/data/data.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/data/data.go b/util/data/data.go index bc719998..0b156ca0 100644 --- a/util/data/data.go +++ b/util/data/data.go @@ -20,6 +20,8 @@ import ( "strconv" "strings" + "encoding/json" + "github.com/abcum/surreal/util/deep" "github.com/abcum/surreal/util/pack" ) @@ -71,6 +73,10 @@ func (d *Doc) Decode(src []byte) *Doc { return d } +func (d *Doc) MarshalJSON() ([]byte, error) { + return json.Marshal(d.Data()) +} + // -------------------------------------------------------------------------------- func (d *Doc) path(path ...string) (paths []string) {