title: In Go Language, how do I unmarshal json to array of object?
body: <p>I have the following JSON, and I want to parse it into array of class:</p>
  
  <pre><code>{
      "1001": {"level":10, "monster-id": 1001, "skill-level": 1, "aimer-id": 301}
      "1002": {"level":12, "monster-id": 1002, "skill-level": 1, "aimer-id": 302}
      "1003": {"level":16, "monster-id": 1003, "skill-level": 2, "aimer-id": 303}
  }
  </code></pre>
  
  <p>Here is what i am trying to do but failed:</p>
  
  <pre><code>type Monster struct {
      MonsterId  int32
      Level      int32
      SkillLevel int32
      AimerId    int32
  }
  
  
  type MonsterCollection struct {
      Pool map[string]Monster
  }
  
  func (mc *MonsterCollection) FromJson(jsonStr string) {
      var data interface{}
      b := []byte(jsonStr)
      err := json.Unmarshal(b, &amp;data)
      if err != nil {
          return
      }
  
      m := data.(map[string]interface{})
  
      i := 0
      for k, v := range m {
  
          monster := new(Monster)
          monster.Level = v["level"]
          monster.MonsterId = v["monster-id"]
          monster.SkillLevel = v["skill-level"]
          monster.AimerId = v["aimer-id"]
  
          mc.Pool[i] = monster
          i++
      }
  
  }
  </code></pre>
  
  <p>The compiler complain about the  v["level"] 
  &lt;&lt; invalid operation. index of type interface().</p>