You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Parse JSON text into a [JObject] instance.# Note: To surface the bug, the text must contain an ARRAY$obj= [Newtonsoft.Json.JsonConvert]::DeserializeObject('{ "foo": [ "bar" ] }')
# Apply default output formatting, which fails due to the bug:
{ $obj|Out-String } | Should -Not-Throw
Expected behavior
The test should succeed.
Actual behavior
The test fails, because the implicit output formatting threw an exception.
Target type System.Collections.IEnumerator is not a value type or a non-abstract class.
(Parameter 'targetType')
Note:
I don't know whether / what other libraries are affected, or whether Newtonsoft.Json is an unusual one.
The bug surfaces only if the input JSON text contains an array.
The bug is a regression from Windows PowerShell, where it doesn't surface.
The error is ultimately the same as in Working directly with certain .NET types, such as Newtonsoft.Json's, is broken: implicit stringification #10652:
Target type System.Collections.IEnumerator is not a value type or a non-abstract class. (Parameter 'targetType')- note how the type name is an interface, not a class.Steps to reproduce
Expected behavior
The test should succeed.
Actual behavior
The test fails, because the implicit output formatting threw an exception.