title: Golang accessing elements of Gin.H
body: <p>trying out the <a href="https://github.com/gin-gonic/examples/tree/master/realtime-advanced" rel="nofollow noreferrer">example</a> to find out if the it can be a pubsub, I wonder if it is possible to parse or access the elements in gin.H map. I want to send a Json in a POST.</p>
  <p>roomPOST() @ route.go</p>
  <pre><code>    ...
      post := gin.H{
          &quot;message&quot;: &quot;{\&quot;12345\&quot;:\&quot;on\&quot;,\&quot;23456\&quot;:\&quot;off\&quot;,}&quot;,
      }
      ...
  </code></pre>
  <p>And I wish to do something with it in streamRoom()</p>
  <p>streamRoom() @ route.go</p>
  <pre><code>    ...
      c.Stream(func(w io.Writer) bool {
          select {
          case msg := &lt;-listener:
              ...
              fmt.Printf(&quot;msg: %s %s\n&quot;, reflect.TypeOf(msg), msg)
              ...
      }
  
  </code></pre>
  <pre><code>msg: gin.H map[message:{&quot;12345&quot;:&quot;on&quot;,&quot;23456&quot;:&quot;off&quot;}]
  </code></pre>
  <p>When trying to access the element in msg, e.g.</p>
  <pre><code>element := msg[&quot;message&quot;].(string)
  </code></pre>
  <p>it throws:</p>
  <pre><code>invalid operation: cannot index msg (variable of type interface{})
  </code></pre>
  <p>Please advise how I can access the elements of Gin.H.</p>