Skip to content

Instantly share code, notes, and snippets.

@uurtech
Created May 28, 2020 14:49
Show Gist options
  • Save uurtech/b8e33baa52087c2c570648d8a7c9a12f to your computer and use it in GitHub Desktop.
Save uurtech/b8e33baa52087c2c570648d8a7c9a12f to your computer and use it in GitHub Desktop.
Golang Json Parse Empty Interface
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
resp, err := http.Get("https://jsonplaceholder.typicode.com/posts/")
if err != nil {
log.Fatal(err)
}
body, _ := ioutil.ReadAll(resp.Body)
var f interface{}
err = json.Unmarshal(body, &f)
fmt.Printf("%+v", f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment