Modules/businessdev.ALbuild.Apps/Private/ConvertTo-BcCallGraphObject.ps1

function ConvertTo-BcCallGraphObject {
    <#
    .SYNOPSIS
        Turns an engine result (dictionaries and lists) into PowerShell objects for callers and JSON output.
    #>

    [CmdletBinding()]
    param([Parameter(Position = 0)] $Value)

    if ($null -eq $Value) { return $null }
    if ($Value -is [System.Collections.IDictionary]) {
        $o = [ordered]@{}
        foreach ($k in $Value.Keys) { $o["$k"] = ConvertTo-BcCallGraphObject $Value[$k] }
        return [PSCustomObject]$o
    }
    if ($Value -is [System.Collections.IEnumerable] -and $Value -isnot [string]) {
        return , @(foreach ($item in $Value) { ConvertTo-BcCallGraphObject $item })
    }
    return $Value
}