|
} elseif ($(if($item -is [Collections.IDictionary]) { $item.get_Keys().Count } else { @($item.psobject.get_Properties()).Count } ) -gt 0) { |
On the array obtained from get_Properties(), use Length property, which is the real property, instead of Count which is a PowerShell automatic property.
While there,
|
foreach ($property in $item.psobject.Properties) { |
Should use method get_Properties() instead of property Properties, but possibly optimize by capturing the array returned while counting the number of available properties in the previous invocation.
PwshOutCSON/ConvertTo-CSON.ps1
Line 180 in 433198f
On the array obtained from
get_Properties(), useLengthproperty, which is the real property, instead ofCountwhich is a PowerShell automatic property.While there,
PwshOutCSON/ConvertTo-CSON.ps1
Line 189 in 433198f
Should use method
get_Properties()instead of propertyProperties, but possibly optimize by capturing the array returned while counting the number of available properties in the previous invocation.