extract json data from body in golang code example
Example: golang get unknown json request data
package main
func fetchJSONResponse(url string) interface{} {
resp, err := http.Get(url)
defer resp.Body.Close()
var target interface{}
body, _ := ioutil.ReadAll(resp.Body)
json.Unmarshal(body, &target)
return target
}
func main() {
jsonResp := fetchJSONResponse("http://someurl.com")
fmt.Println(jsonResp)
}