3

When sending JSON with ServeJSON in Beego, is there a way to skip fields? I know one can skip field for ORM: http://beego.me/docs/mvc/model/models.md#ignore-field but that is just for skipping fields in the database model, it is not related to sending JSON.

NaN
  • 598
  • 3
  • 15

1 Answers1

2

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.

Seraf
  • 118
  • 2
  • 8