title: Printing Empty Json as a result
body: <p>I am trying to retrieve some data from my postgres db and printing them to <code>localhost/db</code> as json. I am succeeding in printing them without json but I need them in json.</p>
  
  <p>main.go:</p>
  
  <pre><code>package main
  
  import (
      "database/sql"
      "encoding/json"
      "fmt"
      "log"
      "net/http"
  
      _ "github.com/lib/pq"
  )
  
  type Book struct {
      isbn   string
      title  string
      author string
      price  float32
  }
  
  var b []Book
  
  func main() {
  
      db, err := sql.Open("postgres", "postgres://****:****@localhost/postgres?sslmode=disable")
  
      if err != nil {
          log.Fatal(err)
      }
      rows, err := db.Query("SELECT * FROM books")
      if err != nil {
          log.Fatal(err)
      }
      defer rows.Close()
  
      var bks []Book
      for rows.Next() {
          bk := new(Book)
          err := rows.Scan(&amp;bk.isbn, &amp;bk.title, &amp;bk.author, &amp;bk.price)
          if err != nil {
              log.Fatal(err)
          }
          bks = append(bks, *bk)
      }
      if err = rows.Err(); err != nil {
          log.Fatal(err)
      }
  
      b = bks
  
      http.HandleFunc("/db", getBooksFromDB)
      http.ListenAndServe("localhost:1337", nil)
  
  }
  
  func getBooksFromDB(w http.ResponseWriter, r *http.Request) {
  
      fmt.Println(b)
      response, err := json.Marshal(b)
      if err != nil {
          panic(err)
  
      }
  
      fmt.Fprintf(w, string(response))
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/8kefD.png" rel="nofollow">This is what I get when I access localhost:1337/db</a></p>
  
  <p>And this is the output on the terminal:</p>
  
  <pre><code> [{978-1503261969 Emma Jayne Austen 9.44} {978-1505255607 The Time Machine H. G. Wells 5.99} {978-1503379640 The Prince Niccolò Machiavelli 6.99}]
  </code></pre>
  
  <p>Anyone knows what is the problem?</p>