github.com/artisanhe/tools@v1.0.1-0.20210607022958-19a8fef2eb04/mq/agent/utils.go (about) 1 package agent 2 3 import ( 4 "encoding/json" 5 ) 6 7 func MarshalData(v interface{}) ([]byte, error) { 8 return json.Marshal(v) 9 } 10 11 func UnmarshalData(data []byte, v interface{}) error { 12 if len(data) == 0 { 13 return nil 14 } 15 return json.Unmarshal(data, v) 16 }