title: Octopus Deploy conditional variable substitution in an array
body: <p><strong>Background</strong></p>
  <p>I'm using Octopus Deploy in a project with Json configuration variable substitution in one of the processes. The Asp.net core project I contribute takes urls &amp; names from the Json config and adds HttpClient instances to reach several endpoints.</p>
  <p>The json looks like this:</p>
  <pre><code> &quot;HttpClientFactoryServices&quot;: [
      {
        &quot;Name&quot;: &quot;ServiceX&quot;,
        &quot;Url&quot;: &quot;http://serviceXurl&quot;
      },
      {
        &quot;Name&quot;: &quot;ServiceY&quot;,
        &quot;Url&quot;: &quot;http://serviceYurl&quot;
      },
      {
        &quot;Name&quot;: &quot;ServiceZ&quot;,
        &quot;Url&quot;: &quot;http://serviceZurl&quot;
      }
    ] 
  </code></pre>
  <p>I want to edit these Url parts depending on the QA an Prod environments. (on Octopus)</p>
  <p>I know there's an array object substitution in Octopus <a href="https://octopus.com/docs/deployment-process/configuration-features/json-configuration-variables-feature#JSONConfigurationVariablesFeature-Arrayvariables" rel="nofollow noreferrer">documentation</a>, but I don't feel comfortable to say</p>
  <blockquote>
  <p>HttpClientFactoryServices:0 = {&quot;name&quot;:&quot;ServiceX&quot;, &quot;url&quot;:...}</p>
  <p>HttpClientFactoryServices:1 = {&quot;name&quot;:&quot;ServiceY&quot;, &quot;url&quot;:...}</p>
  </blockquote>
  <p>as the array can be altered, the objects it holds can have a different structure in the future. Also it looks like a workaround rather than a proper way.</p>
  <p><strong>The Question</strong>
  Is there a way to tell Octopus &quot;find the object which has ServiceX value in the Name property in the array, and set its &quot;Url&quot; property, to  http://serviceX-QA if it's in QA environment, and to http://serviceX-prod if it's in Prod environment?</p>
  <p>Or do you suggest that I change my approach to the HttpClient &amp; Json config?</p>
  <p><strong>Additional info</strong>:
  I used to hold nested objects under HttpClientFactoryServices, before I switched to an object array in the Json config. And it was easy to add property values to them in Octopus, ie:</p>
  <blockquote>
  <p>HttpClientFactoryServices:ServiceX:Url = &quot;http://serviceX&quot;</p>
  </blockquote>
  <p>But in the project code, I had to code &quot;take serviceX from Json, read its Url, add it as an httpClient named service with the name ServiceX&quot;. It looked better to iterate through an array of services.</p>