title: golang: How can i access json decoded field?
body: <p>i have the next JSON data: <a href="http://jsonblob.com/532d537ce4b0f2fd20c517a4" rel="nofollow">http://jsonblob.com/532d537ce4b0f2fd20c517a4</a></p>
  
  <p>So what im trying to iterate ( like foreach in PHP ) is: invoices -> invoice ( is an array )</p>
  
  <p>So, what im trying to do is:</p>
  
  <pre><code>package main
  import (
      "fmt"
      "reflect"
      "encoding/json"
  )
  
  func main() {
      json_string := `{"result":"success","totalresults":"494","startnumber":0,"numreturned":2,"invoices":{"invoice":[{"id":"10660","userid":"126","firstname":"Warren","lastname":"Tapiero","companyname":"ONETIME","invoicenum":"MT-453","date":"2014-03-20","duedate":"2014-03-25","datepaid":"2013-07-20 15:51:48","subtotal":"35.00","credit":"0.00","tax":"0.00","tax2":"0.00","total":"35.00","taxrate":"0.00","taxrate2":"0.00","status":"Paid","paymentmethod":"paypalexpress","notes":"","currencycode":"USD","currencyprefix":"$","currencysuffix":" USD"},{"id":"10661","userid":"276","firstname":"koffi","lastname":"messigah","companyname":"Altech France","invoicenum":"","date":"2014-03-21","duedate":"2014-03-21","datepaid":"0000-00-00 00:00:00","subtotal":"440.00","credit":"0.00","tax":"0.00","tax2":"0.00","total":"440.00","taxrate":"0.00","taxrate2":"0.00","status":"Unpaid","paymentmethod":"paypal","notes":"","currencycode":"USD","currencyprefix":"$","currencysuffix":" USD"}]}}`
  
      var dat map[string]interface{}
      if err := json.Unmarshal([]byte(json_string), &amp;dat); err != nil {
          panic(err)
      }
  
      invoices := dat["invoices"]
  
      fmt.Println("\nJSON-VALUE:",json_string)
      fmt.Println("\nVar type:",invoices)
      fmt.Println("\nVar type using REFLECT:",reflect.TypeOf(invoices))
  
      for index,value := range invoices.invoice {
          fmt.Println(index,value)
      }
  
  }
  </code></pre>
  
  <p>but im receiving errors like: <strong>invoices.invoice undefined (type interface {} has no field or method invoice)</strong> </p>
  
  <p><a href="http://play.golang.org/p/8uTtN6KtTq" rel="nofollow">http://play.golang.org/p/8uTtN6KtTq</a></p>
  
  <p>So please, i need some help here, is my first day with Go.</p>
  
  <p>Thank you very much.</p>