natsio/model/common_response.go

19 lines
366 B
Go
Raw Permalink Normal View History

2022-08-30 04:03:02 +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)
}