title: Go Gin converting json response to base64
body: <p>I am trying to send db query data as json response . Here is my controller :</p>
  
  <pre><code>import (
      "fmt"
      "github.com/json-iterator/go"
      "log"
  )
  
  func GetNewsPapers()  []byte{
      db := GetDB()
  
      var json = jsoniter.ConfigCompatibleWithStandardLibrary
  
      rows, err := db.Queryx(`SELECT title, language, ranking, slug, search_term, logo_url FROM public.news_newspaper`)
      if err != nil {
          log.Println(err)
      }
  
      defer rows.Close()
      tableData := make([]map[string]interface{}, 0)
  
      for rows.Next() {
          entry := make(map[string]interface{})
          err := rows.MapScan(entry)
          if err != nil {
              log.Println(err)
          }
          tableData = append(tableData, entry)
      }
  
      jsonData, _ := json.Marshal(tableData)
  
      fmt.Println(string(jsonData))  // printing expected json
      err = rows.Err()
      if err != nil {
          panic(err)
      }
      return jsonData
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>func (n *NewsPaperController) GetList(c *gin.Context) {
      value := database.GetNewsPapers()
      c.JSON(http.StatusOK, value)
  }
  </code></pre>
  
  <p>Problem is I am getting base64 string as response not the json object I am expecting. If I convert <code>value</code> to string like below, I get human readable values .</p>
  
  <pre><code>c.JSON(http.StatusOK, string(value))
  </code></pre>
  
  <p>But whole response encoded in string like this:</p>
  
  <pre><code>"[{\"language\":\"en\",\"logo_url\":\"..\",\"ranking\":2,\"search_term\":\"..\",\"slug\":\"..\",\"title\":\"....\"}]
  </code></pre>
  
  <p>How do I get json response like below:</p>
  
  <pre><code> [{"language":"en","logo_url":"..","ranking":2,"search_term":"..","slug":"..","title":".."} ] 
  </code></pre>