Hello,
I’m working on creating JSON, for a HTTP API request, and I can’t figure out part of the syntax.
My code is:
$body = [ordered]@{
resourceType='Parameters';
parameter=@{
name='Valueset'
}
}
write-host ($body|ConvertTo-JSON)
I think my approach is correct in that I’m creating a hash table and converting it to JSON? I’m new to Powershell and trying to make sure I’m not teaching myself incorrect ways of doing things.
The specific problem I have is that I need to make parameter an array in two situations:
When I actually have more than one name attribute.
When, as above, I only have one but I need it to be a json array as that’s what the API server is expecting.
I’ve tried several different methods and not been able to get it to work so any advise/guidance would be appreciated.
Thanks