title: Merging json objects in powershell
body: <p>I have json that looks like this:</p>
  
  <pre><code>{
      "Workflow": [
          {
              "Parameters": {
                  "Project": "/Path/To/File",
                  "OtherParam": "True"
              }
          }
      ],
      "Overrides": [
          {
              "Special": {
                  "Parameters": {
                      "NewParam": "NewStuffGoesHere",
                      "OtherParam": "False"
                  }
              }
          }
      ]
  }
  </code></pre>
  
  <p>... where I want to use the <code>Overrides.Special</code> section to add or update fields in the workflow object. In other words, given the json above, I want to do something like this:</p>
  
  <pre><code>$config = Get-Content workflow.json | out-string | ConvertFrom-Json
  $configWithOverrides = Merge-Object $config.Workflow $config.Overrides.Special
  </code></pre>
  
  <p>And end up with something like this:</p>
  
  <pre><code>$configWithOverrides
  
  Parameters
  ----------
  @{Project=/Path/To/File; NewParam=NewStuffGoesHere; OtherParam=False}
  </code></pre>
  
  <p>I can certainly write the <code>Merge-Object</code> function above to add or update values as needed based on what's in the override section, but it seems there should (could?) be a built-in or one-liner way to handle this.</p>
  
  <p>I tried this:</p>
  
  <pre><code>$test = $config.Workflow + $config.Overrides.Special
  </code></pre>
  
  <p>...but that doesn't quite work.</p>
  
  <pre><code>$test
  Parameters
  ----------
  @{Project=/Path/To/File; OtherParam=True}
  @{NewParam=NewStuffGoesHere; OtherParam=False}
  </code></pre>
  
  <p>This enables adding parameters:</p>
  
  <pre><code>&gt;$test.Parameters.NewParam
  NewStuffGoesHere
  </code></pre>
  
  <p>...but it's not so great for updating them</p>
  
  <pre><code>&gt;$test.Parameters.OtherParam
  True
  False
  </code></pre>
  
  <p>Note - in this example, I'm choosing to handle the merge after converting the json to a psobject, but that's not a requirement.</p>