You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
306 B
19 lines
306 B
package utils
|
|
|
|
import "encoding/json"
|
|
|
|
func ObjectToJson(o interface{}) string {
|
|
res, err := json.Marshal(o)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return string(res)
|
|
}
|
|
|
|
func JsonToObject(data string, o interface{}) error {
|
|
err := json.Unmarshal([]byte(data), o)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|