I am trying to send a JSON api request via Powershell script, but nested hashtables (ie. anything more than one level deep) will only render as 'System.Collections.Hashtable' instead of the actual content. For example, if I have a structure like this:
@{
Name = "John Smith";
Age = 28;
siblings = @(
@{
Name = "Jane Smith";
Age = 33;
},
@{
Name = "Bill Smith";
Age = 27;
}
)
}
When I convert to json to send to an application/json rest api, the inner hashtables don't render as the name and age of the siblings, but just as 'System.Collections.Hashtable'. I have not encountered an issue like this with any other language. If I use the function ConvertTo-Json on these inner hashtables, they are rendered as strings instead of json. How do I get nested hashtables to properly render the same way the first level outer hashtables render? I have checked online and I haven't found any solutions that work.
EDIT: I fixed the syntax issues. I will try out your fixes and see if that helps, then respond to your comments.