title: Parsing JSON using struct
body: <p>I'm trying to parse JSON using Go. Can anyone tell me why my code is not working as expected?</p>
  <pre><code>package main
    
  import (
      &quot;encoding/json&quot;
      &quot;fmt&quot;
  )
  type Message struct {
      Name string
      Body string
      Time int64
  }
  
  type Person struct {
      M Message
  }
  
  func get_content() {
  
      body := []byte(`{&quot;person&quot;:{&quot;Name&quot;:&quot;Alice&quot;,&quot;Body&quot;:&quot;Hello&quot;,&quot;Time&quot;:1294706395881547000}}`)
  
      var data Person
      err := json.Unmarshal(body, &amp;data)
      if err != nil {
          panic(err.Error())
      }
      fmt.Printf(&quot;%v&quot;,data.M.Name)
  
  }
  
  func main() {
      get_content()
  }
  
  </code></pre>
  <p>I'm expecting it to print the Name.</p>
  <p><a href="https://play.golang.org/p/tzY5hFUckhD" rel="nofollow noreferrer">Go playground Code</a></p>