Beego c.ServeJson()返回空

Beego c.ServeJson()返回空,go,beego,Go,Beego,我试图在我的golang应用程序中以JSON的形式返回一个结构,如下所示 这是我的代码: type RespJson struct { value1 string `json:"value1"` value2 string `json:"value2"` } func (c *ApiController) Prepare() { c.BaseController.Prepare() } func (c *ApiController) Post() { someDat

我试图在我的golang应用程序中以JSON的形式返回一个结构,如下所示

这是我的代码:

type RespJson struct {
   value1 string `json:"value1"`
   value2 string `json:"value2"`
}

func (c *ApiController) Prepare() {
   c.BaseController.Prepare()
}

func (c *ApiController) Post() {
   someData:= c.GetString("someData")
   moreData:= c.GetString("moreData")

   //do something with data

   var responseJSON RespJson
        responseJSON = RespJson{
            value1:    "dataExample",
            value2:    "dataExample",
        }
        c.Data["json"] = &responseJSON
        c.ServeJSON()

}
然而,当我在邮递员身上测试它时,我总是得到{}


这可能是一件愚蠢的事情,因为我搜索了错误,但没有人得到它,所以感谢您的时间。

在我发现问题时回答我自己的问题

好吧,就像我说的,这是一件愚蠢的事情。。。由于第一个小写字母,我的结构的字段是私有的,因此如果我将结构更改为

type RespJson struct {
  Value1 string `json:"value1"`
  Value2 string `json:"value2"`
}
代码是什么

var responseJSON RespJson
    responseJSON = RespJson{
        Value1:    "dataExample",
        Value2:    "dataExample",
    }
    c.Data["json"] = &responseJSON
    c.ServeJSON()
它按预期工作