PowerShell 7.3 - implementing JSON Deserialization Using ConvertFrom-Json with Nested Structures
I'm stuck trying to I'm having a hard time understanding I'm working with trouble deserializing a JSON string into a PowerShell object using `ConvertFrom-Json`. The JSON structure I'm working with is nested and looks like this: ```json { "name": "John", "age": 30, "address": { "street": "123 Main St", "city": "New York" }, "phones": [ { "type": "home", "number": "123-456-7890" }, { "type": "work", "number": "987-654-3210" } ] } ``` When I use the following PowerShell command: ```powershell $jsonString = '{"name":"John","age":30,"address":{"street":"123 Main St","city":"New York"},"phones":[{"type":"home","number":"123-456-7890"},{"type":"work","number":"987-654-3210"}]}' $person = $jsonString | ConvertFrom-Json ``` I expect to access the name and city directly like `$person.name` and `$person.address.city`, but when I try, I get an behavior that states `$person.address` is not recognized as a valid property. It seems like the object is not being deserialized correctly into nested structures. I also tried adding the `-Depth` parameter like this: ```powershell $person = $jsonString | ConvertFrom-Json -Depth 10 ``` However, the scenario continues. I've verified that the JSON syntax is valid using an online validator. Is there something I'm missing in my approach to handle this nested JSON structure properly? Any suggestions or insights would be greatly appreciated. What's the best practice here? I'm using Powershell 3.11 in this project. I'd really appreciate any guidance on this. My team is using Powershell for this REST API. Any ideas how to fix this?