I found a peculiar quirk this morning about the json transform step and wanted to learn more about it.
A developer added a section of stuff to an appsettings.json, but commented out a couple of the lines within(don’t know why). I went to source control and the package and verified that the lines of config existed but were commented out with a //. Upon deploying to a server and using the structured json transform, I saw that it removed the lines of config entirely. Is this a normal behavior? Is it the type of comment? Could I use instead
here’s an example:
Thanks for reaching out to Octopus Support! I’d be happy to look into the behavior you’re seeing with JSON replacement in your deployments.
I’ve done some testing with various comment methods in a JSON file and have found mixed results. Most attempts, including
/*comment*/, failed because the JSON was invalid. The odd part that I will continue investigating on our side is that
//comment is also technically invalid JSON, so I’m not exactly sure why that’s being treated differently.
I got the lines to stay in my appsettings.json using a comment example I found here, by adding the
// within the element.
I will update you once I have more info on why it behaves differently using your example, and please let me know if you have any other questions for us.