I want to be able to access a struct field that's resulted from a JSON unmarshal, BUT I want to use that same struct to hide the field when it is marshaled.
Example:
type MyStruct struct {
GoodField string `json:"goodField"`
SecretField string `json:"secret"`
}
Incoming JSON gets unmarshaled and the secret
field is accessible
Use the same MyStruct
in the server response but hide the secret
field.
I've looked at using omitempty
and -
tags, not working.