FIX: Merge-JsonSimpleMap

- First time hash is undefined, copying it is not a good
    approach - instead, create a new empty hash and
    copy values in
This commit is contained in:
Iristyle
2013-03-13 10:03:03 -04:00
parent e47b95dd33
commit 03ea687e3e

View File

@@ -120,22 +120,21 @@ function Merge-JsonSimpleMap
if (!$Destination.$Name)
{
$Destination |
Add-Member -Name $Name -Value $SimpleMap -MemberType NoteProperty
Add-Member -Name $Name -Value ([PSCustomObject]@{}) -MemberType NoteProperty
}
else
{
$currentHash = $Destination.$Name
$SimpleMap.PSObject.Properties |
% {
if (!$currentHash.($_.Name))
$key = $_.Name
if (!$currentHash.$key)
{
$currentHash |
Add-Member -Name ($_.Name) -Value $_.Value -MemberType NoteProperty
Add-Member -Name $key -Value $_.Value -MemberType NoteProperty
}
else
{
$currentHash.($_.Name) = $_.Value
}
$currentHash.$key = $_.Value
}
}
}