diff --git a/types/data.go b/types/data.go index b311fec..babdddc 100644 --- a/types/data.go +++ b/types/data.go @@ -1,6 +1,7 @@ package types import ( + "encoding/json" "errors" ) @@ -270,3 +271,17 @@ func (data Data) MustGetTimestamp(key string) Timestamp { value, _ := data.GetTimestamp(key) return value } + +func (data Data) JSON() ([]byte, error) { + bs, err := json.Marshal(&data) + if err != nil { + return nil, err + } + + return bs, nil +} + +func (data Data) MustJSON() []byte { + bs, _ := data.JSON() + return bs +}