-
Notifications
You must be signed in to change notification settings - Fork 380
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
Code generation with serde(default) #524
Comments
Can you please explain, what exactly are you proposing? |
Sorry for the confusion. If you attempt to deserialize json for a proto struct that has 3 fields and the json only has 2 of them present, for example, you will fail in error due to the missing field. I feel it is beneficial to allow for the presence of serde(default) to configure serde_json to use default values for potentially missing items in the json during deserialization. The solution may not be require all fields to be present despite the protobuf definition. Due to #519 I thought in the long time another solution to this issue may be warranted due to native json support. In the short time I hacked the option in to get me moving in this fork commit. |
I see, thanks for the explanation. Well, I know only a little about serde. Your patch looks right, but I'd avoid risking breaking backwards compat unless there are good reasons to. Please let me know if this is needed in rust-protobuf v2. Otherwise better just drop serde support in v3. |
rust-protobuf version 2 is now is maintenance mode. rust-protobuf version 3:
|
It may be a moot point in context of #519, but support for optional fields in JSON input would be useful.
I'm not sure if there is a good clean workaround so I opted to just fork and hack the option in quickly.
The text was updated successfully, but these errors were encountered: