Skip to content

ConvertFrom-Json keys collision: behavior difference between Core and Full #1567

@vors

Description

@vors

Steps to reproduce

'{"a": "first", "a": "last"}' | ConvertFrom-Json

Expected behavior

On the full powershell, i.e. v5.1 (windows)

a
-
last

Actual behavior

ConvertFrom-Json : Can not add property a to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
At line:1 char:33
+ '{"a": "first", "a": "last"}' | ConvertFrom-Json
+                                 ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Environment data

> $PSVersionTable
Name                           Value                                                                                                        
----                           -----                                                                                                        
PSVersion                      5.1.10032.0                                                                                                  
PSEdition                      PowerShellCore                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                      
BuildVersion                   3.0.0.0                                                                                                      
GitCommitId                    v6.0.0-alpha.7                                                                                               
CLRVersion                                                                                                                                  
WSManStackVersion              3.0                                                                                                          
PSRemotingProtocolVersion      2.3                                                                                                          
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.WG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions