title: Deserializing a non-standard json in GO
body: <p>I'm writing a simple app that makes requests to an API that returns a heterogeneous JSON of the type</p>
  <pre><code>{
    &quot;results&quot;: [
      [123, &quot;Zho's Mask&quot;, 10586],
      [345, &quot;Ravaging Superior Studded Coat&quot;, 58]
    ]
  }
  </code></pre>
  <p>Ultimately, I would want to be able to use specific indices from the result response. For example, I would want to be able to just get &quot;Zho's Mask&quot;, or the price: 10586. Here is the API I am using <a href="https://www.gw2tp.com/api" rel="nofollow noreferrer">GW2TP</a>.</p>
  <p>Most of the examples in the GO JSON blogs make reference to simpler or straightforward JSON that does not include nested arrays.</p>
  <p>From what I read, since I know the general look of the JSON response, I can make a GO struct and unmarshall it into an instance of the struct. However, I have not been able to create the correct struct for this job.</p>
  <p>This is my current attempt at creating the appropriate struct</p>
  <pre><code>package main
  
  import (
      &quot;encoding/json&quot;
      &quot;fmt&quot;
      &quot;io/ioutil&quot;
      &quot;log&quot;
      &quot;net/http&quot;
  )
  
  // {&quot;results&quot;:[[123,&quot;Zho's Mask&quot;,3532]]}
  
  type Equipment struct {
      Results []ResArray
  }
  
  type ResArray struct {
      Medium []LastArray
  }
  
  type LastArray struct {
      Info string
  }
  
  func main() {
      res, err := http.Get(&quot;http://api.gw2tp.com/1/items?ids=123&amp;fields=name,sell&quot;)
      if err != nil {
          log.Fatal(err)
      }
  
      var equipment Equipment
  
      data, err := ioutil.ReadAll(res.Body)
      if err != nil {
          fmt.Print(&quot;ReadAll Error: &quot;, err, &quot;\n&quot;)
      }
      err = json.Unmarshal(data, &amp;equipment)
      if err != nil {
          fmt.Print(&quot;Unmarshal error: &quot;, err, &quot;\n&quot;)
      }
  
  }
  </code></pre>
  <p>This is the Unmarshal error:</p>
  <pre><code>Unmarshal error: json: cannot unmarshal array into Go struct field Equipment.Results of type main.ResArray
  </code></pre>
  <p>Lastly, here is my inspiration for my current approach to this desired GO struct
  <a href="https://medium.com/swlh/json-in-golang-an-introduction-8e889c29a83" rel="nofollow noreferrer">JSON in Golang an Introduction</a>.</p>