-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Convert Newtonsoft.Json metadata properties in ConvertFrom-Json #7308
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
Convert Newtonsoft.Json metadata properties in ConvertFrom-Json #7308
Conversation
e1850b4 to
778fcf2
Compare
|
@louistio Would you mind rewording the title and the description for this PR. The associated issue states that the metaproperties are not being converted yet the PR title appears to state that they should be ignored. Thanks, |
|
@dantraMSFT Yes my bad, it is confusing, this PR stated to ignore them as in to tell the serializer not to do anything special with them, not to ignore them as in not convert them. I changed the title now. (I would also amend the commit message but I know you guys don't like rewriting history while a review is active) |
|
@louistio Seems the header should be "Don't convert ..." |
iSazonov
left a comment
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.
Leave a comment
markekraus
left a comment
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.
My comments are not blocking. Otherwise LGTM
|
Upon reviewing the issue, I do not believe this to be a breaking change as this appears to be a regression from 5.1. The behavior in 5.1 was to serialize the meta properties as object properties which is now broekn in 6.0. This PR corrects that regression and IMO is not a breaking change. |
|
@iSazonov I think there is confusion about the naming. The issue is that some values are not converted from |
|
@dantraMSFT Do you have any comments? |
|
@louistio Thanks for your contribution! |
PR Summary
Use
MetadataPropertyHandling.IgnoreinJsonSerializerSettingswhen Deserializing instead of the default (MetadataPropertyHandling.Default). Documentation on this option can be found here and here. BasicallyNewtonsoft.Jsonspecific metadata properties like$id/$type/$refare by default read and used byNewtonsoft.Jsonto deserialize into types, use the same instance for different properties, etc.ConvertFrom-Jsondeserializes into the generic typePSCustomObject, I think it doesn't make sense that these specific properties would not be converted as they are part of the json object. This restrict people from using these properties if they are not usingNewtonsoft.Json, but even more likely, it restrict them from manipulating the entire raw json data of an object serialized with the library (which is probably what they want to do, otherwise they would be using the library directly to deserialize).I don't know how "breaking" of a change this is considered to be, I would assume not many people rely on the current behavior, but it is changing with this PR.
Fixes #7307
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests