Skip to content

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

Closed

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

Activity

  1. vors commented on Jul 29, 2016

    @vors
    CollaboratorAuthor
  2. modified the milestone: on Aug 4, 2016
  3. adityapatwardhan commented on Sep 20, 2016

    @adityapatwardhan
    Member

    sergei (@vors) I am not able to repro this issue anymore.

    PS D:\OpenPowershell\PowerShell> '{"a": "first", "a": "last"}' | ConvertFrom-Json
    
    a
    -
    last
    
    
    PS D:\OpenPowershell\PowerShell> $PSVersionTable
    
    Name                           Value
    ----                           -----
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    CLRVersion
    PSEdition                      Core
    PSVersion                      6.0.0-alpha
    GitCommitId                    v6.0.0-alpha.10-24-g735983b08666fa3bac5cb2805124ce89fdede68c
    SerializationVersion           1.1.0.1
    BuildVersion                   3.0.0.0
    
  4. modified the milestones: , on Feb 28, 2017
  5. SteveL-MSFT commented on Mar 18, 2017

    @SteveL-MSFT
    Member

    I don't repro it either with alpha.17

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

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