-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add custom JSONEncoder for model serialization #19595
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
Conversation
e4e71cd to
6ec7641
Compare
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.
|
/azp run python - core - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@mccoyp _utils.py has been moved into utils folder. |
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.
When the conversation starts regarding deserialization - we will want to make sure we support weird .NET timestamps (with extra decimal places). When that conversation happens - what we do to serialize round-tripped values will be important as well.
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.
Do we really need to import a private type from a private submodule?
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 think we should rename _FixedOffset to FixedOffset. But not sure if it is worth...
|
/azp run python - autorest - pr |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Does this still need int() around seconds?
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 wouldn't think so, since this AttributeError should only come up if seconds is an integer. seconds.is_integer() works when seconds is a float on 2.7. 3.6, and 3.9 when I test locally
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.
This is currently part of the public API - which I don't think it should be, at least to start with.
Can we make it private?
|
/azp run python - core - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - core - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - core - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This adds a custom JSONEncoder that can serialize
datetimeobjects (dates,times,datetimes, andtimedeltas) in UTC ISO 8601 format, as well asbytesandbytearrays in base64 strings.