Files
go-utils/json.go
2018-11-11 00:27:32 +02:00

17 lines
299 B
Go

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)
}