Reputation: 4791
I have a simple object with 1 parameter being an ArrayList of objects. I am using ConvertTo-Json
to output this to Json. However even if I set -Depth 1000
I still see truncation of data.
Structure is:
Object
Property
Property - ArrayList of Object2.
Object 2 is a simple collection of properties.
The output I see is:
{
"CheckDate": "03 February 2016 10:12:30",
"Versions": [
{
},
{
}
]
}
Calling convert on the ArrayList directly all the data is shown. It would appear as if the -Depth
argument is not being honored and is stuck at 2.
edit: Code to create object
$returnValue = New-Object System.Object
$returnValue | Add-Member -type NoteProperty -name CheckDate -value (Get-Date).DateTime
$versions = New-Object System.Collections.ArrayList
# This bit is in a loop.
$app = New-Object System.Object
$app | Add-Member -type NoteProperty -Name Name -Value $name
$app | Add-Member -type NoteProperty -Name Version -Value $version
$versions.Add($app)
# Back out of the loop.
$returnValue | Add-Member -type NoteProperty -name Versions -value $versions
Upvotes: 3
Views: 991
Reputation: 42073
Use PSObject
instead of System.Object
. Unfortunately, I cannot provide any details, it is some internal "magic" of ConvertTo-Json
. Interestingly, it is enough to use PSObject
instead of the second System.Object
.
Upvotes: 3