title: How to unmarshal dynamic json objects with Golang
body: <p>let me start by telling that I'm pretty recent in the Go world.</p>
  
  <p>What I'm trying to do is to read the json I get from a JSON API (I don't control). Everything is working fine, I can show the received ID and Tags too. But the fields field is a little bit different, because its a dynamic array. </p>
  
  <p>I can receive from the api this:</p>
  
  <pre><code>{
      "id":"M7DHM98AD2-32E3223F",
      "tags": [
          {
              "id":"9M23X2Z0",
              "name":"History"
          },
          {
              "id":"123123123",
              "name":"Theory"
          }
      ],
      "fields": {
          "title":"Title of the item",
          "description":"Description of the item"
      }
  }
  </code></pre>
  
  <p>Or instead of <code>title</code> and <code>description</code> I could receive only <code>description</code>, or receive another random object like <code>long_title</code>. The objects return may differ completly and can be an infinite possibility of objects. But it always returns objects with a key and a string content like in the example.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>type Item struct {
      ID string `json:"id"`
      Tags []Tag `json:"tags"`
      //Fields []Field `json:"fields"`
  }
  
  // Tag data from the call
  type Tag struct {
      ID string `json:"id"`
      Name string `json:"name"`
  }
  
  // AllEntries gets all entries from the session
  func AllEntries() {
      resp, _ := client.Get(APIURL)
      body, _ := ioutil.ReadAll(resp.Body)
  
      item := new(Item)
      _ = json.Unmarshal(body, &amp;item)
  
      fmt.Println(i, "-&gt;", item.ID)
  }
  </code></pre>
  
  <p>So the Item.Fields is dynamic, there is no way to predict what will be the key names, and therefore as far I can tell, there is no way to create a struct for it. But again, I'm pretty newbie with Go, could someone give me any tips? Thanks</p>