natsio/model/common_response.go

19 lines
366 B
Go
Raw Normal View History

2022-08-23 07:26:49 +00:00
package model
import "encoding/json"
// CommonResponseData ...
type CommonResponseData struct {
Data interface{} `json:"data"`
Error string `json:"error"`
}
// ParseData ...
func (c CommonResponseData) ParseData(resultPointer interface{}) error {
b, err := json.Marshal(c.Data)
if err != nil {
return err
}
return json.Unmarshal(b, resultPointer)
}