Add data json

tags/v1.0.7 v1.0.7
Stanly 4 years ago
parent 2a78c5e845
commit 56b2b22f66

@ -1,6 +1,7 @@
package types package types
import ( import (
"encoding/json"
"errors" "errors"
) )
@ -270,3 +271,17 @@ func (data Data) MustGetTimestamp(key string) Timestamp {
value, _ := data.GetTimestamp(key) value, _ := data.GetTimestamp(key)
return value 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
}

Loading…
Cancel
Save