title: How can I access JSON column in mysql db from golang
body: <p>I have a table in mysql with 3 columns Profile string, userInformation JSON, badge string.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Profile</th>
  <th style="text-align: center;">userInformation</th>
  <th style="text-align: center;">badge</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">https://ps.w.org/metronet-profile-picture/assets/icon-256x256.png?rev=2464419</td>
  <td style="text-align: center;">{&quot;name&quot;: &quot;Suzan Collins&quot;, &quot;points&quot;: 10000, &quot;countryName&quot;: &quot;Poland&quot;}</td>
  <td style="text-align: center;">assets/batcherPage/gold.png</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>This is my struct:</p>
  <pre><code>type BatchersData struct {
      ProfileURL      string          `json:&quot;profileUrl&quot;`
      UserInformation UserInformation `json:&quot;userInformation&quot;`
      Badge           string          `json:&quot;badge&quot;`
  }
  type UserInformation struct {
      Points      int64  `json:&quot;points&quot;`
      Name        string `json:&quot;name&quot;`
      CountryName string `json:&quot;countryName&quot;`
  }
  
  </code></pre>
  <p>What I want to do is make a select query on this table ie GET and retrieve every information..</p>
  <p>using this code, I have accessed Profile and Badge :</p>
  <pre><code>func getBatchers(c *gin.Context) {
  
      var batchers []BatchersData
      rows, err := db.Query(&quot;SELECT profileUrl, badge FROM Batchers_page_db&quot;)
  
      if err != nil {
          return
      }
      defer rows.Close()
      for rows.Next() {
          var batcher BatchersData
          if err := rows.Scan(&amp;batcher.ProfileURL, &amp;batcher.Badge); err != nil {
              return
          }
          batchers = append(batchers, batcher)
      }
      if err := rows.Err(); err != nil {
          return
      }
      c.IndentedJSON(http.StatusOK, batchers)
  }
  </code></pre>
  <p>But I want to access JSON column ie UserInformation as well. I know that the query will be</p>
  <pre><code>rows, err := db.Query(&quot;SELECT * FROM Batchers_page_db&quot;)
  </code></pre>
  <p>But i'll have to make a change in this statement</p>
  <pre><code>if err := rows.Scan(&amp;batcher.ProfileURL, &amp;batcher.Badge);
  </code></pre>
  <p>I have tried doing this : but nothing works</p>
  <pre><code>rows.Scan(&amp;batcher.ProfileURL,&amp;batcher.UserInformation, &amp;batcher.Badge);
  </code></pre>