I've a json like this, I want to add a line key:value for each line in my file.
For example add a comma and the value KC-NA-asplan-PROJECTS-DEV-01 before the curly bracket.
[
{
"name": "/subscriptions/uifaghy78923/resourceGroups/KC-NA-RSGP-PROJECTS-DEV-01/providers/Microsoft.Web/serverfarms/KC-NA-asplan-PROJECTS-DEV-01"
},
{
"name": "/subscriptions/uifaghy78923/resourceGroups/KC-NA-RSGP-PROJECTS-DEV-01/providers/Microsoft.Web/serverfarms/KC-NA-asplan-PROJECTS-DEV-02"
}
]
$file="pathtojson"
$jsonContent = Get-Content $file | ConvertFrom-Json;
$appserviceplan= $jsonContent.name;
foreach ($app in $appserviceplan) {
$app.Split('/')[8]
}
I'd like to add the corrisponding $app.Split('/')[8] in every line in order to have
"name": "/subscriptions/uifaghy78923/resourceGroups/KC-NA-RSGP-PROJECTS-DEV-01/providers/Microsoft.Web/serverfarms/KC-NA-asplan-PROJECTS-DEV-01", "value": "KC-NA-asplan-PROJECTS-DEV-01"
},