Closed ventayol closed 10 years ago
I'm using the render to send back json entities. It's working fine, but I would like to remove some fields from the response. For example, I don't want to send the user password back to the client.
Is there any option to do this?
To ignore a field you just define it like this:
Field int `json:"-"`
and let encoding/json deal with the rest. It's documented here.
encoding/json
Thanks @cryptix
This solved the problem I had but it's not the best option for my project.
I think I'm going to use omitempty so I can keep using binding and his required validation. So I'll set the field to nil after I query it.
omitempty
required
I'm using the render to send back json entities. It's working fine, but I would like to remove some fields from the response. For example, I don't want to send the user password back to the client.
Is there any option to do this?