unmarshal json
This commit is contained in:
16
json.go
Normal file
16
json.go
Normal 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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user