title: How to pass JSON response in Go BeeGo framework?
body: <p>I'm building microservices app with go and beego. I'm trying to pass JSON response from service A to service B as following: </p>
  
  <pre><code>func (u *ServiceController) GetAll() {
      req := httplib.Get("http://localhost/api/1/services")
      str, err := req.String()
      // str = {"id":1, "name":"some service"}
      if err != nil {
          fmt.Println(err)
      }
      u.Data["json"] = str
      u.ServeJSON()
  }
  </code></pre>
  
  <p>However, when I send the response I actually double json encoding:</p>
  
  <pre><code>"{\"id\":\"1\",\"name\":\"some service\"}"
  </code></pre>
  
  <p>Finally, this is the solution I came up with: </p>
  
  <pre><code>func (u *ServiceController) GetAll() {
      req := httplib.Get("http://localhost/api/1/services")
      str, err := req.String()
      if err != nil {
          fmt.Println(err)
      }
  
      strToByte := []byte(str)
      u.Ctx.Output.Header("Content-Type", "application/json")
      u.Ctx.Output.Body(strToByte)
  }
  </code></pre>