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:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user