mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Add '-AsArray' parameter to 'ConvertoTo-Json' command (#6438)
Add `-AsArray` parameter to `ConvertoTo-Json` command to always pack the output string in array brackets, even if the input is a single object.
This commit is contained in:
1 parent
cc3ffd8349
commit
dfa11d7f5e
2 files changed
+24
-2
No files matched your search
@@ -35,4 +35,17 @@ Describe 'ConvertTo-Json' -tags "CI" {
|
||||
$ps.InvocationStateInfo.State | Should -BeExactly "Stopped"
|
||||
$ps.Dispose()
|
||||
}
|
||||
|
||||
It "The result string is packed in an array symbols when AsArray parameter is used." {
|
||||
$output = 1 | ConvertTo-Json -AsArray
|
||||
$output | Should -BeLike "``[*1*]"
|
||||
|
||||
$output = 1,2 | ConvertTo-Json -AsArray
|
||||
$output | Should -BeLike "``[*1*2*]"
|
||||
}
|
||||
|
||||
It "The result string is not packed in the array symbols when there is only one input object and AsArray parameter is not used." {
|
||||
$output = 1 | ConvertTo-Json
|
||||
$output | Should -BeExactly '1'
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user