Answers for "golang get unknown json request data"

1

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)
}
Posted by: Guest on October-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language