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

oryband picture oryband  路  3Comments

olegsobchuk picture olegsobchuk  路  3Comments

Bloomca picture Bloomca  路  3Comments

lilee picture lilee  路  3Comments

gplume picture gplume  路  3Comments