JSON Configuration Variables

Zhen's Avatar

Zhen

19 Jan, 2018 07:36 AM

Hi All,

I read this article here https://octopus.com/docs/deploying-applications/deploying-asp.net-core-web-applications/json-configuration-variables-feature, about how to replace a value in a Json array by suing the zero-based index of the array in the variable name.

However, it doesn't fix my needs.

I have three Json files, all of them have similar structure as below but with different objects in $values

{
 "Policies" :
    "$values": [
         {
           "$type": "",
           ...
         },
         {
           "$type": "",
           ...
         }
        ....
   ]
}

My questions is if I'm using zero-based index to replace the value with variable e.g. Policies:$values:7, all three json files would be replaced with the same value. however, I only want to replace Policies:$values:7 value for one of the json files. is there any way I can replace json file by specifying the variable name?

  1. Support Staff 1 Posted by Kenneth Bates on 23 Jan, 2018 02:20 AM

    Kenneth Bates's Avatar

    Hi,

    Thanks for getting in touch! When defining files to perform substitution on, any entries that exist within these files that match project variables will be substituted with those variable values. If the variable exists in multiple defined files, it will substitute in both, and unfortunately there's no way to limit that in any way. You could accomplish this by creating a unique project variable name, but that would require you to alter this specific JSON file as well. Would that be a possible solution?

    Sorry it's not better news! Don't hesitate to reach out if you have any further questions or concerns going forward.

    Best regards,

    Kenny

  2. 2 Posted by zhen on 24 Jan, 2018 05:51 AM

    zhen's Avatar

    Thanks Kenny,

    Thanks for the response above. In the end, I used powershell script to replace the value.

    Cheers,
    Zhen

  3. Support Staff 3 Posted by Kenneth Bates on 24 Jan, 2018 11:26 PM

    Kenneth Bates's Avatar

    Hi Zhen,

    Thanks for following up and letting me know the outcome! Please don't hesitate to reach out if you have any further questions going forward. :)

    Best regards,

    Kenny

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac