Enable data docs to self encode to JSON

This commit is contained in:
Tobie Morgan Hitchcock 2017-02-20 09:46:26 +00:00
parent 997633eaf4
commit 969179660b

View file

@ -20,6 +20,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"encoding/json"
"github.com/abcum/surreal/util/deep" "github.com/abcum/surreal/util/deep"
"github.com/abcum/surreal/util/pack" "github.com/abcum/surreal/util/pack"
) )
@ -71,6 +73,10 @@ func (d *Doc) Decode(src []byte) *Doc {
return d return d
} }
func (d *Doc) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Data())
}
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
func (d *Doc) path(path ...string) (paths []string) { func (d *Doc) path(path ...string) (paths []string) {