我正在创建一个JSON格式的字符串。输出是正确的,除了所有qoutes已被\ char替换而不是“
{
\$schema\: \https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#\,
\contentVersion\: \1.0.0.0\,
\parameters\: {
\type\: \web\,
\name\: \Cluster\,
\hockeyAppToken\: \\,
\hockeyAppId\: \\,
\regionId\: \southcentralus\,
\requestSource\: \IbizaAIExtension\
}
}
生成Json的代码
$fullDoc = '
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": ' + $armsettings + '}'
$json = $fullDoc | ConvertTo-Json -depth 100
$json = $json.Replace("\r","")
$json = $json.Replace("\n",([Environment]::NewLine))
$json = $json.Replace("@{","{")
$json = $json.Trim()
$json = $json.Replace($json.Substring(0,1),"")
Write-Host $json
有关如何解决此问题的任何想法?
这是正确的格式化文档
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"type": {
"value": "web"
},
"name": {
"value": "Cluster"
},
"hockeyAppToken": {
"value": ""
},
"hockeyAppId": {
"value": ""
},
"regionId": {
"value": "southcentralus"
},
"requestSource": {
"value": "IbizaAIExtension"
}
}
}
答案 0 :(得分:0)
$fullDoc | ConvertTo-Json | ConvertFrom-Json