Example:
type T struct {
Foo int
}
response,will tips:
{"Foo":42}
but i want to get
{"foo":42}
In many cases, it is very difficult to define lowercase one by one. Is there a simple way?
Add the json property in the struct like so:
type T struct {
Foo int `json:"foo"`
}
That tells what to name the key when serializing to json
Most helpful comment
Add the json property in the struct like so:
That tells what to name the key when serializing to json