I have struct
type tySurvey struct {
Id int64 `json:\"id,omitempty\"`
Name string `json:\"name,omitempty\"`
}
<
use json.Number
type tySurvey struct {
Id json.Number `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}
This is handled by adding ,string
to your tag as follows:
type tySurvey struct {
Id int64 `json:"id,string,omitempty"`
Name string `json:"name,omitempty"`
}
This can be found about halfway through the documentation for Marshal.
Please note that you cannot decode the empty string by specifying omitempty
as it is only used when encoding.