Public Access
Let practice.json add fields entity.json doesn't have, not just replace them
Merge-Config assigned override values with '=', which throws SetValueInvocationException when the property doesn't exist on the base object - so a practice.json could only override fields already present in entity.json. AJMATS's practice.json supplies insurance_path/pdf_path that CAMBS's entity.json lacks entirely, which crashed the merge. Use Add-Member -Force (handles both add and replace), copy whole sections missing from the base, skip _comment keys, and replace scalar sections directly.
This commit is contained in:
+8
-2
@@ -97,10 +97,16 @@ function Merge-Config($base, $override) {
|
||||
if (-not $override) { return $base }
|
||||
$merged = $base | ConvertTo-Json -Depth 10 | ConvertFrom-Json
|
||||
foreach ($section in $override.PSObject.Properties) {
|
||||
if ($null -ne $merged.PSObject.Properties[$section.Name]) {
|
||||
if ($section.Name -like "_*") { continue }
|
||||
$baseSection = $merged.PSObject.Properties[$section.Name]
|
||||
if ($null -eq $baseSection) {
|
||||
$merged | Add-Member -NotePropertyName $section.Name -NotePropertyValue $section.Value
|
||||
} elseif ($section.Value -is [System.Management.Automation.PSCustomObject]) {
|
||||
foreach ($prop in $section.Value.PSObject.Properties) {
|
||||
$merged.$($section.Name).$($prop.Name) = $prop.Value
|
||||
$merged.$($section.Name) | Add-Member -NotePropertyName $prop.Name -NotePropertyValue $prop.Value -Force
|
||||
}
|
||||
} else {
|
||||
$merged.$($section.Name) = $section.Value
|
||||
}
|
||||
}
|
||||
return $merged
|
||||
|
||||
Reference in New Issue
Block a user