我正在将Azure资源组中的JSON导出为以下格式的JSON文件:
```json
但是这样会在所有地方加上“
```json
{ "example": "示例" }
```Export-AzureRmResourceGroup -ResourceGroupName $SourceResourceGroupName -Path $filename
然后我获取文件的JSON内容,将其应用到一个变量中:
$SourceJSON = Get-Content $filename -Raw
我想将这个转换为PowerShell对象:
$SourceJSONRG = $SourceJSON | ConvertFrom-Json
我随后查看对象内部的资源:
$SourceJSONRG.resources
但是storageProfile
部分为空:
然而,通过比较JSON($SourceJSON
),可以发现storageProfile
不为空:
我已经尝试使用Format-Custom -Depth
选项进行更深入的查看:
$SourceJSONRG = $SourceJSON | ConvertFrom-Json
$SourceJSONRG = $SourceJSONRG | Format-Custom -Depth 99
但是这样会在所有地方加上“
class PSCustomObject
”,我不想要这个。
我想要做的最终目标是将JSON转换为PowerShell对象,对其进行更改,例如更改磁盘的URI,然后将其转换回JSON以便用于部署到Azure。换句话说,将JSON转换为PowerShell对象使我更容易处理它。New-AzureRmResourceGroupDeployment -ResourceGroupName $TargetResourceGroupName -TemplateFile "C:\Users\marc\AppData\Local\Temp\test20692192.json"