I have a Json file with combination of strings, substrings and array as attached below.
I tried to fetch the Id using the psobject and reading the JSON file as RAW but didnt workout.
$json = (Get-Content "C:\Users\rasto\OneDrive\Desktop\Job_board\output.json" -Raw) | ConvertFrom-Json
$json.psobject.TypeNames.item
Further I tried to run loop but didnt work as well.
$data = Get-Content "Path to json file" | Out-String | ConvertFrom-Json
foreach ($line in $data) {
$line.id
}
Json File:
{
"data": [
{
"id": "146993",
"text": "value1"
},
{
"id": "14699",
"text": "value2"
}
],
"meta": {
"newest_id": "146",
"oldest_id": "146",
"result_count": 79
}
}
I want to extract the values in field "id" using PowerShell.
Output:
146993 14699