title: Convert interface{} to int
body: <p>I'm trying to get a value from a JSON and cast it to int but it doesn't work, and I don't know how to do it properly.</p>
  
  <p>Here is the error message:</p>
  
  <pre><code>...cannot convert val (type interface {}) to type int: need type assertion
  </code></pre>
  
  <p>And the code:</p>
  
  <pre><code>    var f interface{}
      err = json.Unmarshal([]byte(jsonStr), &amp;f)
      if err != nil {
          utility.CreateErrorResponse(w, "Error: failed to parse JSON data.")
          return
      }
  
      m := f.(map[string]interface{})
  
      val, ok := m["area_id"]
      if !ok {
          utility.CreateErrorResponse(w, "Error: Area ID is missing from submitted data.")
          return
      }
  
      fmt.Fprintf(w, "Type = %v", val)   // &lt;--- Type = float64
      iAreaId := int(val)                // &lt;--- Error on this line.
      testName := "Area_" + iAreaId      // not reaching here
  </code></pre>