I have below json
{
"abc": [
{ "def": [ "", "" ] },
{ "ghi": [ "", "" ] },
{ "xyz" : ["\\[dbo\\].\\[abc1\\]", "\\[dbo\\].\\[def1\\]"] }
]
}
i want to read this json and convert string of xyz element to string array in powershell using below code but its not working.
$json = Get-Content "path to json file" | Out-String
$json = $json | ConvertFrom-Json
GetArrayFromJson -json $json
$global:array
Function GetArrayFromJson(){
Param(
$json
)
$global:array= ''
$global:array
$global:array= $json.abc.xyz
$global:array
}
ConvertFrom-Json
it is already Powershell. You can output it with$json.abc.xyz