Skip to content

Don't serialize to json ETS properties for DateTime and string types - #15665

Merged
Rob Holt (rjmholt) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:json-ets
Jul 12, 2021
Merged

Rob Holt (rjmholt) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:json-ets

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Jun 24, 2021 •

Copy link
Copy Markdown
Member

PR Summary

PowerShell automatically adds extended properties to DateTime (specifically DisplayHint) objects that is used with formatting. This is intended to be "internal", but when converted to JSON, those extra properties turn what should be a json datetime to a complex object. For string types, if the user has added extended properties, this can result in recursive serialization behavior.

The @PowerShell/powershell-committee agreed to special case both DateTime and string types to not serialize any extended properties when converting to JSON.

PR Context

Fix #5797

PR Checklist

…Cmdlet/JsonObject.cs

Co-authored-by: Ilya <darpa@yandex.ru>
@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jul 2, 2021
@ghost ghost added the Review - Needed The PR is being reviewed label Jul 10, 2021
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@rjmholt
Rob Holt (rjmholt) merged commit adc236c into PowerShell:master Jul 12, 2021
@ghost ghost removed the Review - Needed The PR is being reviewed label Jul 12, 2021
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the json-ets branch July 13, 2021 02:28
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.8 milestone Jul 13, 2021
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.8 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConvertTo-Json: unexpected behavior with objects that have ETS properties (NoteProperty, ScriptProperty)

3 participants