github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/task/constants/marshaller.go (about) 1 package constants 2 3 import "encoding/json" 4 5 func MarshalData(v interface{}) ([]byte, error) { 6 return json.Marshal(v) 7 } 8 9 func UnmarshalData(data []byte, v interface{}) error { 10 if len(data) == 0 { 11 return nil 12 } 13 return json.Unmarshal(data, v) 14 } 15