I have some JSON like this (which came from a PSObject):
[
{
"cf_workflow_1": 1212,
"cf_workflow_2": null,
"cf_workflow_3": null
},
{
"cf_workflow_1": null,
"cf_workflow_2": 9797,
"cf_workflow_3": null
},
{
"cf_workflow_1": 6262,
"cf_workflow_2": null,
"cf_workflow_3": null
}
]
I want to pull out an array that is simply:
(1212,9797,6262)
How would I go about doing that?
Here is some sample code to work with:
$tickets = @"
[
{
"cf_workflow_1": 1212,
"cf_workflow_2": null,
"cf_workflow_3": null
},
{
"cf_workflow_1": null,
"cf_workflow_2": 9797,
"cf_workflow_3": null
},
{
"cf_workflow_1": 6262,
"cf_workflow_2": null,
"cf_workflow_3": null
}
]
"@
$ticketsObject = $tickets | ConvertFrom-Json
#Show the ticket data
$ticketsObject | Format-Table -AutoSize
#Create an array to hold all the non-null workflow numbers
#It should eventually contain the value (1212,9797,6262)
$workflowNumbers = @()
#Not sure what to do here to return only the non-null workflow numbers as an array?
$workflowNumbers = $ticketsObject | foreach{$_}