-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: add default values parameter to to_json #164
Conversation
Codecov Report
@@ Coverage Diff @@
## master #164 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 862 862
Branches 149 149
=========================================
Hits 862 862
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
||
json2 = Squid.to_json(s).replace(" ", "").replace("\n", "") | ||
assert ( | ||
json2 == '{"name":"Steve","massKg":0}' or json2 == '{"massKg":0,"name":"Steve"}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ordering not stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No but it shouldn't matter for json objects right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should matter, I just was curious if you were running into problems during testing.
instance, | ||
*, | ||
use_integers_for_enums=True, | ||
including_default_value_fields=True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yon-mg Could you open a follow up PR to update the docstring below?
This will result in a change in behavior for someone already using this method Protobuf defaults to False
for this option. https://googleapis.dev/python/protobuf/latest/google/protobuf/json_format.html#google.protobuf.json_format.MessageToJson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. I did not change the way google.protobuf.json_format.MessageToJson
works. In fact this method message.MessageMeta.to_json
should call MessageToJson
in the same way as it did before if no changes are made to the additional parameter I added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I did neglect to update the docstring for this method which I will update shortly if that's what you mean.
🤖 I have created a release \*beep\* \*boop\* --- ## [1.12.0](https://www.github.com/googleapis/proto-plus-python/compare/v1.11.0...v1.12.0) (2020-11-20) ### Features * add default values parameter to to_json ([#164](https://www.github.com/googleapis/proto-plus-python/issues/164)) ([691f1b2](https://www.github.com/googleapis/proto-plus-python/commit/691f1b24454502c4ac49a88a09d1c9fbc287b2bd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
No description provided.