Azure / Azure/azure-cli

Nested Json objects output as escaped strings

Open
#25,506 4 comments 0 reactions 1 assignee Claimed by @albertofori View on GitHub
act-codegen-extensibility-squad App Configuration Auto-Assign customer-reported Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### **This is autogenerated. Please review and update as needed.**

## Describe the bug

Json output that has nested objects are being treated as strings and escaped instead of properly serialized

**Command Name**
`az appconfig kv show`

**Errors:**
No errors

## To Reproduce:
Run this in PowerShell 7.3.2

```
$escapedNestedJson = @"
{
"contentType": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"etag": "A9U7H9eKbG0PLrqIbV9VeXVcWxb",
"key": "Test:Test",
"label": "MyLabel",
"lastModified": "2021-12-01T22:54:28+00:00",
"locked": false,
"tags": {},
"value": "{\"uri\":\"https://mykeyvault.vault.azure.net/secrets/test\"}"
}
"@

$notConvenientObject = ConvertFrom-Json $escapedNestedJson
Write-Host "Uri Doesn't Work: $($notConvenientObject.value.uri)"
Write-Host "I don't want to do this: $($($notConvenientObject.value | ConvertFrom-Json).Uri)"

$fixedNestedJson = @"
{
"contentType": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"etag": "A9U7H9eKbG0PLrqIbV9VeXVcWxb",
"key": "Test:Test",
"label": "MyLabel",
"lastModified": "2021-12-01T22:54:28+00:00",
"locked": false,
"tags": {},
"value": {"uri":"https://mykeyvault.vault.azure.net/secrets/test"}
}
"@

$convenientObject = ConvertFrom-Json $fixedNestedJson
Write-Host "Uri Works: $($convenientObject.value.uri)"

```

## Expected Behavior

Nested Json objects are correctly serialized / deserialized instead of being considered a string

## Environment Summary
```
Windows-10-10.0.19044-SP0
Python 3.10.8
Installer: MSI

azure-cli 2.45.0

Extensions:
aks-preview 0.5.98
image-copy-extension 0.2.11

Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1
```
## Additional Context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.