diff --git a/json.go b/json.go new file mode 100644 index 0000000..cdfe81a --- /dev/null +++ b/json.go @@ -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) +}