title: Unmarshaling a json http response
body: <p>I have very recently started playing with GO and I am trying to unmarshal a JSON response from <a href="http://www.oref.org.il/WarningMessages/alerts.json" rel="nofollow">http://www.oref.org.il/WarningMessages/alerts.json</a>.<br>
  For some reason that I can't understand the unmarshaling failed, the unmarshalled struct is empty (my guess is that it is somehow related to encoding).  </p>
  
  <p>Below is the code, any help is appreciated.</p>
  
  <p>Thanks,
  Itay</p>
  
  <pre><code>package main
  
  import (
    "fmt"
    "io/ioutil"
    "net/http"
    "encoding/json"
  )
  
  const alertsUrl = "http://www.oref.org.il/WarningMessages/alerts.json"
  
  type Record struct {
    Id string `json:id`
    Title string `json:title`
    Data []string `json:data`
  }
  
  func main() {
    client := &amp;http.Client{}
    req, err := http.NewRequest("GET", alertsUrl, nil)
    perror(err)
  
    req.Header.Add("Content-Type", "application/json; charset=utf-8")
    res, err := client.Do(req)
    perror(err)
  
    defer res.Body.Close()
    body, err := ioutil.ReadAll(res.Body)
    perror(err)
  
    var record Record
    json.Unmarshal(body, &amp;record)
    fmt.Println(record)
  }
  
  func perror(err error) {
    if err != nil {
      panic(err)
    }
  }
  </code></pre>