Skip to content

ConvertFrom-Json does not convert Newtonsoft.Json specific metadata properties in root object #7307

@adamgauthier

Description

@adamgauthier

Steps to reproduce

> '{"$id": 1, "$type": "System.String", "id": "value"}' | ConvertFrom-Json
  1. Add $id and $type properties to a json object
  2. Pipe object to ConvertFrom-Json Cmdlet
  3. Notice that $id and $type properties are missing from resulting PSCustomObject

Expected behavior

ConvertFrom-Json does not ignore properties when deserializing into generic PSCustomObject, regardless of their name.

> '{"$id": 1, "$type": "System.String", "id": "value"}' | ConvertFrom-Json

$id $type         id
--- -----         --
  1 System.String value

Actual behavior

> '{"$id": 1, "$type": "System.String", "id": "value"}' | ConvertFrom-Json

id
--
value

Additional Notes

  • Issue does not occur when metadata properties are deeper in the hierarchy.
  • Other Newtonsoft.Json metadata properties include $values and $ref.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.3
PSEdition                      Core
GitCommitId                    v6.1.0-preview.3
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions