-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
If the JSON contains duplicate keys with the same casing, then only the last key is used and the others are silently thrown away. The code in JsonObject.cs here actually caters for this case and would throw an error but it never gets to that stage because JsonConvert.DeserializeObject here does not throw when there are duplicate keys and simply decides to take the last one.
Steps to reproduce
'{ "key":"value1", "key":"value2" }' | ConvertFrom-JsonExpected behavior
Either a warning that duplicated keys were disregarded or an error stating that duplicate keys are not allowed unless e.g something like. a -Force switch is used. Given that this would be a breaking change, it will probably have to be a warning.
Actual behavior
Only the last key is used when there are duplicate keys
key
---
value2Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta.8
PSEdition Core
GitCommitId v6.0.0-beta.8-20-g0d5a6fbd71c31043d0eda82f7b0e2d4fb0431322
OS Microsoft Windows 10.0.15063
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
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module