I have a json that looks something this
{
"ApiSettings": {
"EnableSwagger": true,
"UrlListeners": [
"http://localhost:9000"
],
"DebugMode": true
},
}
And have some powershell that looks like this:
$UrlListeners = "http://(Ipofmymachine):9000"
$JsonFile = Get-Content $destinationDirectory\appsettings.json -raw | ConvertFrom-Json
$JsonFile.ApiSettings.UrlListeners = $UrlListeners
$JsonFile | ConvertTo-Json -Depth 9 | Set-Content $destinationDirectory\appsettings.json
The issue is that when the PowerShell is ran it converts the UrlListeners in the appsettings.json into a string, whereas it needs to stay as an array. Is there a way to force this value as an array?
Thanks
[0]), not the whole (parent) array:$JsonFile.ApiSettings.UrlListeners[0] = $UrlListeners