utrack / clay

Proto-first minimal server platform for gRPС+REST+Swagger APIs
MIT License
289 stars 39 forks source link

fix skiping fields in json response which have zero value #40

Closed komly closed 6 years ago

komly commented 6 years ago

After this changes default json marshaler won't skip fields with zero values in response body.

ts := &types.Timeslot{
    Start: 0,
    Duration: 2,
}

now we will response with:

{"start":0,"duration":2}

instead of

{"duration":2}
utrack commented 6 years ago

It breaks proto convention and current behaviour. Servers can control it via OverrideMarshaler("application/json",MarshalerPbJSON{ ... EmitDefaults: true ...}).