Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ protected override void BeginProcessing()
/// </summary>
protected override void ProcessRecord()
{
if (InputObject != null)
{
_inputObjects.Add(InputObject);
}
_inputObjects.Add(InputObject);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ Describe 'ConvertFrom-Json Unit Tests' -tags "CI" {
{ $nestedJson | ConvertFrom-Json -AsHashtable:$AsHashtable } |
Should -Throw -ErrorId "System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand"
}

It 'Can convert null' {
'null' | ConvertFrom-Json | Should -Be $null
Comment thread
iSazonov marked this conversation as resolved.
$out = '[1, null, 2]' | ConvertFrom-Json
$out.Length | Should -Be 3

# can't compare directly to array as Pester doesn't handle the $null
$out[0] | Should -Be 1
$out[1] | Should -Be $null
$out[2] | Should -Be 2
}
}

Describe 'ConvertFrom-Json -Depth Tests' -tags "Feature" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@ Describe 'ConvertTo-Json' -tags "CI" {

@{ 'abc' = "'def'" } | ConvertTo-Json @params | Should -BeExactly $expected
}

It "Should handle null" {
[pscustomobject] @{ prop=$null } | ConvertTo-Json -Compress | Should -BeExactly '{"prop":null}'
$null | ConvertTo-Json -Compress | Should -Be 'null'
ConvertTo-Json -Compress $null | Should -Be 'null'
1, $null, 2 | ConvertTo-Json -Compress | Should -Be '[1,null,2]'
}
}