-
Notifications
You must be signed in to change notification settings - Fork 1.6k
jsonpb should support custom JSON serialization #331
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
Comments
ping |
@bcmills, pinging you since |
"Last to touch the package" isn't a great heuristic. I think @dsnet, @cherrymui, and @randall77 have been working on proto stuff lately. |
Agreed, it isn't. But outsiders have pretty poor visibility into anything better, and I was hoping to get some feedback on this vs. letting it languish like so many other issues and pull requests. Thanks for tagging the relevant folks! |
\cc @cybrcodr, who will be handling some of the jsonpb-related PRs and issues. |
@cybrcodr: ping |
I think this sounds reasonable for dynamic messages. But it would be better for WKT's JSON (de)serialization be as implemented right now. I'll review your PR soon. |
Fixed in #325 |
This would be done by delegating to the message if it implements
json.Marshaler
orjson.Unmarshaler
.FWIW, this could simplify how the well-known types are handled, e.g. no need to special-case them in this package. (So, in a way, this issue relates to #169.)
Both the binary and text encodings already support the same concept, where a message can implement a particular interface (proto.Marshaler/proto.Unmarshaler, encoding.TextMarshaler/encoding.TextUnmarshaler) to customize serialization/de-serialization. This just extends that same concept to JSON encoding/decoding.
I've also opened a pull request that implements the change: #325
I think consistency with binary and text marshaling is a reasonable justification for the change. But I also have my own reason for the change: allow users of a dynamic message library to use
jsonpb
as they would with any otherproto.Message
.The text was updated successfully, but these errors were encountered: