Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit default values in marshalled JSON (with tests) #628

Conversation

flw-cn
Copy link

@flw-cn flw-cn commented Apr 28, 2018

Repost for closes #233, #242 and #508. cc @ornithocoder @philipithomas @achew22.

philipithomas and others added 2 commits April 28, 2018 13:44
In order to make APIs more restful, require the marshaler to emit
default values. By default, it omits empty types. This causes
unexpected REST behavior by omitting all false values or zero-valued
integers.

If you like to override its behavior back, use the WithMarshalerOption:

```go
gwmux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{OrigName: true, EmitDefaults: false}))
```

Closes grpc-ecosystem#233
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@flw-cn flw-cn force-pushed the feature/origin-issue-233-emit-default branch from 79a8e83 to f588bc4 Compare April 28, 2018 07:01
@flw-cn
Copy link
Author

flw-cn commented Apr 30, 2018

Sorry, I notice that there is already a PR #540 do the same thing, even more.

So, just close this.

@flw-cn flw-cn closed this Apr 30, 2018
pityonline pushed a commit to pityonline/grpc-gateway that referenced this pull request Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support emitting default values in JSON
4 participants