CodexBloom - Programming Q&A Platform

PowerShell 7.3 - working with 'NotSupportedException' When Using 'ConvertFrom-Json' with Nested JSON Structures

👀 Views: 56 đŸ’Ŧ Answers: 1 📅 Created: 2025-08-27
powershell json convertfrom-json PowerShell

I'm not sure how to approach I'm performance testing and I've looked through the documentation and I'm still confused about I'm experiencing a `NotSupportedException` when trying to deserialize a nested JSON structure into PowerShell objects using `ConvertFrom-Json`... My input JSON looks like this: ```json { "name": "John Doe", "age": 30, "address": { "street": "123 Main St", "city": "Anytown" }, "phoneNumbers": [ { "type": "home", "number": "123-456-7890" }, { "type": "work", "number": "987-654-3210" } ] } ``` When I run the following PowerShell command: ```powershell $json = Get-Content -Path "C:\path\to\file.json" -Raw $data = $json | ConvertFrom-Json ``` I receive the behavior message: ``` ConvertFrom-Json : Exception of type 'System.NotSupportedException' was thrown. ``` I have tried ensuring that the JSON is correctly formatted and validated it using various online JSON validators, and it seems to be fine. I also checked that the `Get-Content` command is loading the entire file correctly with the `-Raw` parameter. However, I still need to seem to convert the JSON. I've even attempted to simplify the JSON structure, but the behavior continues. Is there a specific limitation with `ConvertFrom-Json` in PowerShell 7.3 when handling nested JSON objects or arrays? Are there any workarounds or alternative methods to deserialize this data structure correctly? Any guidance would be greatly appreciated! My development environment is Windows. Thanks, I really appreciate it! For reference, this is a production REST API. Any ideas what could be causing this?