title: Convert Go map to json
body: <p>I tried to convert my Go map to a json string with <code>encoding/json</code> Marshal, but it resulted in a empty string.</p>
  
  <p>Here's my code :</p>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "fmt"
  )
  
  type Foo struct {
      Number int    `json:"number"`
      Title  string `json:"title"`
  }
  
  func main() {
      datas := make(map[int]Foo)
  
      for i := 0; i &lt; 10; i++ {
          datas[i] = Foo{Number: 1, Title: "test"}
      }
  
      jsonString, _ := json.Marshal(datas)
  
      fmt.Println(datas)
      fmt.Println(jsonString)
  }
  </code></pre>
  
  <p>My output is :</p>
  
  <pre><code>map[9:{1 test} 2:{1 test} 7:{1 test} 3:{1 test} 4:{1 test} 5:{1 test} 6:{1 test} 8:{1 test} 0:{1 test} 1:{1 test}]
  
  []
  </code></pre>
  
  <p>I really don't know where I'm wrong. Thank you for your help.</p>