Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "encoding/json"
  6.     "net/http"
  7.     "io/ioutil"
  8. )
  9.  
  10. type data struct { 
  11.        
  12.         Target     string          `json:"target"`
  13.         Datapoints [][]interface{} `json:"datapoints"`
  14. }
  15.  
  16. func main(){
  17.     stuff := data{}
  18.  
  19.     info, err := http.Get("URLWITHJSONRESPONSE")
  20.  
  21.     if err != nil {
  22.         panic(err.Error())
  23.     }
  24.  
  25.     res, err := ioutil.ReadAll(info.Body)
  26.  
  27.     if err != nil {
  28.         panic(err.Error())
  29.     }
  30.  
  31.     json.Unmarshal(res, &stuff)
  32.  
  33.     fmt.Println(res)
  34.     fmt.Println(stuff.Target)
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement