Cannot parse json output due to duplicate keys
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
Some commands return json values with duplicate keys when case-insensitive.
Here is an example:
`az vm list-skus --location centralus --size "Standard_D4s_v5" --all -o json | ConvertFrom-Json`
```
ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the
duplicated keys 'Name' and 'name'.
At line:1 char:9
+ $json | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [ConvertFrom-Json], InvalidOperationException
+ FullyQualifiedErrorId : DuplicateKeysInJsonString,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
```
This is also an issue with ConvertFrom-Json not being case-sensitive. However, is it possible to restrict the output of az cli to not include duplicate case-insensitive keys?
The other reason I point this out is because the name field is not really being used:
```
...
"zoneDetails": [
{
"Name": [
"3",
"2",
"1"
],
"capabilities": [
{
"name": "UltraSSDAvailable",
"value": "True"
}
],
"name": null
}
],
...
```
This lowercase 'name' being set to null seems to not be serving any purpose.
### Related command
`az vm list-skus`
### Errors
ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the
duplicated keys 'Name' and 'name'.
### Issue script & Debug output
N/A
### Expected behavior
Any command with `-o json` being piped to ConvertFrom-Json should always successfully result in an object.
### Environment Summary
"azure-cli": "2.53.1",
"azure-cli-core": "2.53.1",
"azure-cli-telemetry": "1.1.0",
"extensions": {}
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.