NaN NaN - 6 months ago 53
JSON Question

Skip field in Beego when sending JSON

When sending JSON with ServeJSON in Beego, is there a way to skip fields? I know one can skip field for ORM: but that is just for skipping fields in the database model, it is not related to sending JSON.


You can use the struct tag "-".

It should looks like :

type MyStruct struct {
    Id      int     `json:"id"`
    Hidden  string  `json:"-"`

It also works for the orm definition.