I'm experimenting with the new Visual Studio
one and I see that the new project structure and configuration make heavy use of the files JSON
, to the detriment of the XML
one used before in the web.config
, etc.
The thing is that I would like to comment out some dependencies in the file config.json
and I find that, using it //
to comment out a line, the syntax colorizer works correctly, but the compiler doesn't buy it.
Is there any special syntax for this kind of comments at least in the configuration files?
The syntax colorizer flags it, but doing build clearly catches the error (see image below).
My recommendation in this particular case, where you want to temporarily disable the dependency , is to create a new section in the configuration file, example here I am moving the Azure Storage reference to this section, when I want to put it back I move it to the correct section.
This avoids changing the dependency name, because then the engine will look for a dependency that won't resolve and can lead to other errors.
The problem is that JSON is not JavaScript (see www.json.org , rfc4627 , rfc7159 and the next suggestion) and therefore is not recognized when parsing it.
The typical solution suggested ( see ) is to add a comment type property like:
You can specify several values with the same key but the last one has priority over the previous one, knowing this you can use the following but I don't know if this will be the best way, but maybe it will help you.
If you just want to disable a certain key in a configuration file without deleting it, just rename it; the engine will ignore any unknown keys (and presumably your code will too, if you use custom configuration files). A good convention is, as josejuan suggests, to add an underscore ("_") at the beginning of the name; this way you can see at a glance which keys are "commented out".