-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Official stance on comments in appsettings.json #26254
Comments
Hello @kimjamia ... This comes up every few years, and it is a good time to hear if there are any updates from the team. I recall back in 2015 👴😄 the following discussion: aspnet/Announcements#24 (comment) Reminder on the history (from Wikipedia):
@JamesNK ... What's the latest news on comments in JSON files? Are the concerns still that they aren't spec and external parsers may choke (per Eilon's remark 7 years ago) ... so the team still generally frowns on the idea? |
Comments are intentionally allowed in appsettings.json. You can add that to the docs. |
What are the rules for use so that the parser doesn't choke?
|
JSON comments behave like JS (or C#). Both styles are supported. |
for vscode add below to settings.json
|
BTW... to get Visual Studio Code to stop complaining, do this: https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json/47834826#47834826 |
Another option is to rename your Then add this near the top of Program.cs:
Then right click on each appsettings file and make sure to set Copy to output directory to Copy if newer, as otherwise these files no longer automatically get copied if you change the extension. Now you can add comments to all of your jsonc files, and not have to instruct other developers to change their editor settings to get the file to show up without syntax highlighting errors. |
…aware that comments are not legal JSON, but function in .NET - see dotnet/AspNetCore.Docs#26254 (comment)
…aware that comments are not legal JSON, but function in .NET - see dotnet/AspNetCore.Docs#26254 (comment)
Given that comments work in appsettings.json and it's a pretty common question too, it would be useful to clarify the official stance on this page.
One very helpful possibility would be to instruct how to configure the JSON configuration provider to explicitly support comments.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Associated WorkItem - 33225
The text was updated successfully, but these errors were encountered: