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,24 +120,23 @@ function Merge-JsonSimpleMap
if (!$Destination.$Name) if (!$Destination.$Name)
{ {
$Destination | $Destination |
Add-Member -Name $Name -Value $SimpleMap -MemberType NoteProperty Add-Member -Name $Name -Value ([PSCustomObject]@{}) -MemberType NoteProperty
} }
else
{ $currentHash = $Destination.$Name
$currentHash = $Destination.$Name $SimpleMap.PSObject.Properties |
$SimpleMap.PSObject.Properties | % {
% { $key = $_.Name
if (!$currentHash.($_.Name)) if (!$currentHash.$key)
{ {
$currentHash | $currentHash |
Add-Member -Name ($_.Name) -Value $_.Value -MemberType NoteProperty Add-Member -Name $key -Value $_.Value -MemberType NoteProperty
}
else
{
$currentHash.($_.Name) = $_.Value
}
} }
} else
{
$currentHash.$key = $_.Value
}
}
} }
function Create-CustomObjectKey function Create-CustomObjectKey