title: Testing JSON posts in Golang
body: <p>I am trying to test a route I created to handle POSTing JSON data.</p>
  
  <p>I am wondering how to write a test for this route.</p>
  
  <p>I have the POST data in a <code>map[string]interface{}</code> and I am creating a new request like so:</p>
  
  <pre><code>mcPostBody := map[string]interface{}{
      "question_text": "Is this a test post for MutliQuestion?",
  }
  body, err = json.Marshal(mcPostBody)
  req, err = http.NewRequest("POST", "/questions/", bytes.NewReader(body))
  </code></pre>
  
  <p>However, <code>t.Log(req.PostFormValue("question_text"))</code> logs a blank line so I don't think I am setting the body correctly.</p>
  
  <p>How can I create a POST request with JSON data as the payload in Go?</p>