Skip to content

Instantly share code, notes, and snippets.

@stantonk
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stantonk/9501046 to your computer and use it in GitHub Desktop.
Save stantonk/9501046 to your computer and use it in GitHub Desktop.
messing http & json in go
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "encoding/json"
func main() {
resp, err := http.Get("https://graph.facebook.com/sproutsocialinc")
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
var profile map[string]interface{}
if err := json.Unmarshal(body, &profile); err != nil {
panic(err)
}
name := profile["name"]
fmt.Println("name =", name)
for k, v := range profile {
fmt.Println(k, v, "\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment