I am iterating JSON object in PowerShell using below code
$awsFileResponse = '{
"commitId":"opb274750f582ik",
"blobId":"io6956a1a967243514e194lk54b86",
"filePath":"PowershellScript.ps1",
"fileMode":"NORMAL",
"fileSize":5755,
"fileContent":"7"
}'
foreach($KeyParam in $awsFileResponse)
{
Write-Host 'Ashish'
Write-Host $KeyParam
Write-Host $KeyParam.NAME
Write-Host $KeyParam.VALUE
if($KeyParam.NAME -eq 'fileContent')
{
$fileContentResponse = $KeyParam.VALUE
Write-Host $fileContentResponse
}
}
I am not getting the exact output that I am looking for.
- it is not printing anything for the below lines Write-Host $KeyParam Write-Host $KeyParam.NAME Write-Host $KeyParam.VALUE
- it is not going to the inside if the condition