Attempting to extract a particular value from a nested JSON response in Powershell.
Im kind of new to using PSObjects but have some experience with REST APIs. I am performing a GET method on a REST endpoint and getting the following back.
{
"value": [
{
"id": 2370,
"customFields": [
"@{id=60; caption=Mu0026S Agreement Status ; type=Text; entryMethod=List; numberOfDecimals=0; value=Active}",
"@{id=68; caption=Maintenance Renewal Notes; type=Text; entryMethod=EntryField; numberOfDecimals=0}",
"@{id=81; caption=Reseller; type=Text; entryMethod=List; numberOfDecimals=0}",
"@{id=105; caption=Product Type; type=Text; entryMethod=List; numberOfDecimals=0; value=GoAnywhere}"
]
}
],
"Count": 1
}
So far so, good but I am unsure of how to extract the “value” field which contains “GoAnywhere” from the final nested string.
I have tried this.
$agreementsResponse | ConvertFrom-Json | ForEach-Object{$_.value} | Select customFields
and it is getting me a single string in an Object.
customFields
------------
{@{id=60; caption=M&S Agreement Status ; type=Text; entryMethod=List; numberOfDecimals=0; value=Active}, @{id=68; caption=Maintenance Renewal Notes; type=Text; entryMethod=EntryField; numberOfDecimals=0}, @{id=8...
Any help would be mucho appreciated
Chris Payne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.