Powershell ConvertTo-json with embedded hashtable
It's a trouble with the depth, the default value is 2, can you try :
ConvertTo-json @($val) -Depth 5
-Depth $([int32]::MaxValue)
specifies infinite depth (maximum possible for ConvertTo-Json cmdlet)