What im trying to do is getting one specific value from nested JSON. Using array keys as expression.
Array with keys and values:
$AccountService = @{
'root.branch.setting1'= 'Val1'
'root.branch.setting2'= 'Val2'
'root.branch.setting3'= 'Val3'
}
Create JSON Object
$json = Get-Content 'C:\Users\ramosfer\Documents\test.json' | ConvertFrom-Json
Get every key from array using a loop to get the value from the JSON. Expecting something like this in the Expression ($json.root.branch.setting1)
$AccountService.GetEnumerator() | % {
$json | Select-Object @{Name="Val"; Expression={$json.$_}}
}
Use this $json.$_ and expect something like this
Val
---
Val1
Val2
Val3
Invoke-Expression "`$json.$_"