Gin: response a json,how could i make the cases "lowercase"?

Created on 1 Apr 2019  路  1Comment  路  Source: gin-gonic/gin

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?

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodingPapi picture CodingPapi  路  3Comments

oryband picture oryband  路  3Comments

nxvl picture nxvl  路  3Comments

frederikhors picture frederikhors  路  3Comments

boneq picture boneq  路  3Comments