JSON object variable converts to string

According to the docs: "You can also replace an entire object. For the example above, you could set Octopus variable weatherApi to a value of {"url":"test.weather.com","key":"TEST7654321"}"

However, I have a variable named Logging:Slack set to this: {“WebHookUrl”:"[redacted]",Channel: “investoristalerts”}
(except the “[redacted]” is a URL containing information that should not be posted publicly, of course)

The file this is to be substituted into contains this:
{
“Logging”: {
“LogLevel”: “Debug”,
“Slack”: null
}
}

(Other irrelevant parts of the hierarchy removed so that this post is a sensible length.)

When variable substitution is performed on the appropriate JSON file, I wind up with this:
{
“Logging”: {
“LogLevel”: “Debug”,
“Slack”: “{\“WebHookUrl\”:\”[redacted]",Channel:\“testingalerts\”}"
}
}

Notice how the object has been treated as a string, and the double-quotes escaped before doing the substitution?

How do I get Octopus to substitute the hierarchical object, as per the documentation, rather than treating the object as a string?

(And just to be extra annoying, the forum needed me to escape the escaping slashes in the output example.)

After a long series of experiments, the answer seems to be that we can substitute one JSON object for another, but we cannot substitute a JSON object for anything that is not an object. Nor can we substitute a JSON object for null, despite the fact that in Javascript/ECMAscript and JSON, null is technically an object.

Hi @inv-services,

Thank you for getting in touch, and I appreciate the update after your experimenting! I’ve run through some tests based on your findings and I’m seeing the same outcome. I’d like to bring this up with my team to see if there’s any reason for this behavior that I can’t see, or if it’s something we should handle better.

Sorry for the confusion this unexpected behavior caused, and please don’t hesitate to reach out with any questions in the meantime. :slight_smile:

Best regards,

Kenny

Hi Kenny.

If it’s not behaviour that your team can improve, I’d suggest at least updating the doc (linked in my original post) to make the behaviour clear. It’s not really something I’d want to have everybody have to discover through experimentation.

Kind regards,
Travis

Hi Travis,

I certainly agree. I’ll make sure to do that if it ends up being needed. My apologies for the inconvenience, but I do greatly appreciate you sharing your findings and input.

Best regards,

Kenny