Last active
          August 29, 2015 13:57 
        
      - 
      
- 
        Save stantonk/9501046 to your computer and use it in GitHub Desktop. 
    messing http & json in go
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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