I'm trying to return a struct as a JSON in my golang app, as seen here
And this is my code:
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()
}
However, when I test it on postman I always get {}
It's probably a dumb thing because I searched for the error and no one is getting it, so thanks for your time.