title: Parsing string to enum from JSON in Golang
body: <p>I have an enum defined as</p>
  
  <pre><code>type MyEnum int
  
  const(
     FirstEnum MyEnum = iota
  )
  </code></pre>
  
  <p>Then, I have a json that has the key-value pair <code>"Key": "FirstEnum"</code>. I'm unmarshalling like this.</p>
  
  <pre><code>var data map[string]interface{}
  err := json.Unmarshal([]byte(json), &amp;data)
  x := data["key"].(MyEnum)
  </code></pre>
  
  <p>When I run this, however, I get the error:</p>
  
  <pre><code>panic: interface conversion: interface {} is string, not ps.Protocol [recovered]
          panic: interface conversion: interface {} is string, not ps.Protocol
  </code></pre>
  
  <p>Is there a way to get this to work like a normal conversion of a string representation of a enum to enum type in Go?</p>