NaN NaN - 1 year ago 161
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download