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
{{ message }}
Repository navigation
Add an -AsArray switch to ConvertTo-Json to support unconditional conversion to a JSON array #6327
Similar to how @(...) ensures treatment of any value as an array, it would be handy if an -AsArray switch could instruct ConvertTo-Json to treat its input as an [ultimately JSON] array, so you can guarantee that your pipeline input is treated as an array, even if it happens to be a single item only:
Wishful thinking:
>$in=1; $in|ConvertTo-Json-AsArray
[
1
]
# scalar 1 was treated as an array>$in=1,2; $in|ConvertTo-Json-AsArray
[
1,2
]
# Input that already is an array is left as-is
changed the title [-]Add switch `-AsArray` to ConvertTo-Json to support unconditional conversion as an array[/-][+]Add an -AsArray switch to ConvertTo-Json to support unconditional conversion to a JSON array[/+]on Mar 6, 2018
Activity
[-]Add switch `-AsArray` to ConvertTo-Json to support unconditional conversion as an array[/-][+]Add an -AsArray switch to ConvertTo-Json to support unconditional conversion to a JSON array[/+]kalgiz commentedon Mar 20, 2018
Fix proposal in #6438.
kalgiz commentedon Mar 23, 2018
Fixed in #6438.