I have a JSON file, where I need to add multiple IDs to locations for name "Test1".
{
"SuppressTraceLog": false,
"Pattern": "^/App/Test/\\?frame1=Detail.asp%3Frigter%3srecrd%12saemkey%3D(?\u012fid\u006e\\d+)",
"PatternGroup": "id",
"Locations": [
{
"Ids": [ "12", "13", "14"],
"Name": "TEST1",
"UrlFormat": "http://test.com/"
},
{
"Ids": [ "42", "43" ],
"Name": "TEST2",
"UrlFormat": "http://test.com/"
},
{
"Ids": ["9", "10"],
"Name": "TEST3",
"UrlFormat": null
}
]
}
Right now I am adding more values to the Ids
node by getting the JSON file and updating its locations as below:
$a = Get-Content $jsonFilePath -Raw | ConvertFrom-Json
$a.Locations | where {$_.Name -eq 'Test1'} | foreach {$_.Ids = ([string]$dusIds)}
$a | ConvertTo-Json | Set-Content $jsonFilePath
However, once I set the content the output is wrong and the IDs looks like,
"Locations": [
{
"Ids": "12, 13, 14",
"Name": "TEST1",
"UrlFormat": "http://test.com/"
},
{
"Ids": "42, 43" ,
"Name": "TEST2",
"UrlFormat": "http://test.com/"
},
{
"Ids": "9, 10",
"Name": "TEST3",
"UrlFormat": null
}
]