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

fix: support binary and dateTime in JSON #3128

Merged
merged 1 commit into from
May 26, 2023
Merged

Conversation

karaatanassov
Copy link
Contributor

This change adds support for binary and dateTime in JSON.

For binary golang []byte JSON serialization matches the vCenter format. Thus adding the name ot the maps was enough.

For dateTime the format of time.Time Marshaler and Unmarshaler matches vCenter format. The discriminator code required support for custom marshaling logic. In addition the name had to be mapped.

Description

Please include a summary of the change and which issue is fixed. Please also
include relevant motivation and context. List any dependencies that are required
for this change.

Closes: #3127

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update
  • Build related change

How Has This Been Tested?

  • Unit tests

Checklist:

  • My code follows the CONTRIBUTION
    guidelines of
    this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Copy link
Contributor

@dekp dekp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

vim25/json/discriminator.go Outdated Show resolved Hide resolved
@karaatanassov
Copy link
Contributor Author

@akutz I tried addressing your comments. I posted aggregate single commit here.

You can see the change related to your comments in karaatanassov@1233895

I had to switch assertEqual to us the built-in reflect.DeepEqual as that provides good handling of corner cases like nil

akutz
akutz previously approved these changes May 26, 2023
@akutz
Copy link
Member

akutz commented May 26, 2023

Wait on #3136 before merging this

This change adds support for `binary` and `dateTime` in JSON.

For `binary` golang `[]byte` JSON serialization matches the vCenter
format. Thus adding the name ot the maps was enough.

For `dateTime` the format of `time.Time` `Marshaler` and `Unmarshaler`
matches vCenter format. The discriminator code required support for
custom marshaling logic. In addition the name had to be mapped.

To support `nil` value fields move `assertEqual` to use
`reflect.DeepEqual`.

Closes: vmware#3127
@akutz akutz merged commit b2f6113 into vmware:main May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] vim25 JSON does not support dateTime and binary in OptionValue
4 participants