title: Unmarshalling a json array in golang
body: <p>I have a question regarding the golang unmarshalling . I was trying to unmarshal Json array but it is giving nil result for one decoding while it is successful in the other. I don't understand the reason behind it. Is it a mistake in the code or expected? </p>
  
  <pre><code>package main
  
  import "fmt"
  import "encoding/json"
  
  type PublicKey struct {
      Id int
      Key string
  }
  
  type KeysResponse struct {
      Collection []PublicKey
  }
  
  func main() {
      keysBody := []byte(`[{"id": 1,"key": "-"},{"id": 2,"key": "-"},{"id": 3,"key": "-"}]`)
      keys := make([]PublicKey,0)
  
      json.Unmarshal(keysBody, &amp;keys)//This works
      fmt.Printf("%#v\n", keys)
      response := KeysResponse{}
      json.Unmarshal(keysBody, &amp;response)//This doesn't work
      fmt.Printf("%#v\n", response)
  
  }
  </code></pre>
  
  <p><a href="http://play.golang.org/p/L9xDG26M8-" rel="nofollow">http://play.golang.org/p/L9xDG26M8-</a></p>