unmarshal json

This commit is contained in:
Gardient
2018-11-11 00:27:32 +02:00
parent 417cd8763f
commit 502fd53d06

16
json.go Normal file
View File

@@ -0,0 +1,16 @@
package utils
import (
"encoding/json"
"io"
"io/ioutil"
)
// UnmarshalJSON will unmarshal json from response body
func UnmarshalJSON(reader io.Reader, v interface{}) {
responseBody, err := ioutil.ReadAll(reader)
PanicOnError(err)
err = json.Unmarshal(responseBody, &v)
PanicOnError(err)
}