Hi,
I'm building JSON to send in an HTTP API call, and one aspect of the syntax has me stuck.
Here's the code:
$payload = [ordered]@{
resourceType = 'Parameters';
parameter = @{
name = 'Valueset'
}
}
write-host ($payload | ConvertTo-JSON)
Am I right that defining a hash table and then turning that into JSON is the correct approach? As a Powershell newcomer, I want to avoid picking up bad habits while teaching myself.
What I specifically need is an array for parameter under two circumstances:
If there's actually more than one name attribute.
If there's just one, like here, but the API expects that value to be represented as a json array.
I've attempted a few approaches without success, so I'd welcome any guidence on getting this right.
Cheers