PowerShell 7.3 - Trouble with Converting a Hashtable to JSON with Nested Properties
I've been banging my head against this for hours. I've been banging my head against this for hours. This might be a silly question, but I'm trying to convert a hashtable containing nested properties to JSON format in PowerShell 7.3, but I'm running into issues with the nested structure not being serialized correctly. My hashtable looks something like this: ```powershell $myHashtable = @{ Name = 'John Doe' Age = 30 Address = @{ Street = '123 Main St' City = 'Anytown' State = 'CA' } Hobbies = @('Reading', 'Hiking', 'Coding') } ``` When I use the `ConvertTo-Json` cmdlet, I run the following command: ```powershell $json = $myHashtable | ConvertTo-Json -Depth 3 ``` However, the resulting JSON output seems to flatten the nested `Address` property, and the output I get is: ```json { "Name": "John Doe", "Age": 30, "Address": "System.Collections.Hashtable", "Hobbies": [ "Reading", "Hiking", "Coding" ] } ``` I'm not seeing the detailed properties of the `Address`. I tried increasing the `-Depth` parameter, but it doesn't seem to make a difference. I've also checked the type of `Address`, and it appears to be a hashtable, which I thought was supported. Is there a specific way to handle nested hashtables in PowerShell when converting to JSON? Any suggestions would be greatly appreciated! Any pointers in the right direction? This is happening in both development and production on Windows 11.