grpc-ecosystem / grpc-gateway

gRPC to JSON proxy generator following the gRPC HTTP spec
https://grpc-ecosystem.github.io/grpc-gateway/
BSD 3-Clause "New" or "Revised" License
17.96k stars 2.21k forks source link

Is there any way we can remove fields from the response json in grpc-gateway? #710

Closed chaitanya9186 closed 6 years ago

johanbrandhorst commented 6 years ago

If you set your marshaller to not EmitDefaults, and then return the zero value of that field, it will not be included in the returned JSON.

This begs the question though, what are you trying to do here?

vtolstov commented 6 years ago

does it possible to modify EmitDefaults per Service in runtime.NewServeMux ?

vtolstov commented 6 years ago

i have compat api and new api. In compat i need to EmitDefaults: true, but in new - not

johanbrandhorst commented 6 years ago

@vtolstov No, I'm afraid you'll have to create a separate ServeMux with the other settings and register your service to that ServeMux instead.

vtolstov commented 6 years ago

thanks, but how to deal with two different ServeMux in one http.Server ?

vtolstov commented 6 years ago

https://github.com/mennanov/fieldmask-utils this is works fine

johanbrandhorst commented 6 years ago

Closing this as OP seems inactive.