Given this Json:
{
“StudentInfo":{
“first-name": “xyz",
“Student_id": "123-xyz"
}
}
I could read the value for student_id using the code below.
$config = Get-Content -Raw $Config
$configObject = ConvertFrom-Json –InputObject $config
$StudentId = $configObject.StudentInfo.Student_id
However, I am unable to read the value for "first-name" as powershell is treating it to be a command instead of variable.Changing key name is not an option for me.
How can we retrieve the value for "first-name" using powershell 5.1?