golang get unknown json request data

Solutions on MaxInterview for golang get unknown json request data by the best coders in the world

showing results for - "golang get unknown json request data"
Antonio
01 Feb 2016
1package main
2
3func fetchJSONResponse(url string) interface{} {
4	resp, err := http.Get(url)
5	defer resp.Body.Close()
6	var target interface{}
7	body, _ := ioutil.ReadAll(resp.Body)
8	json.Unmarshal(body, &target)
9	return target
10}
11
12func main() {	
13	jsonResp := fetchJSONResponse("http://someurl.com")
14	fmt.Println(jsonResp)
15}