Open gbowne1 opened 5 days ago
I know what treesitter will complain about syntax, And Intellij Suite will also complain in certain situations
Took a look with debbuger tru treesitters parser, when parsing json file with jsonc parser it expects compressed json and not json with comments
ah, That makes sense. The warnings about comments in a .json file went away after I changed the extension to .jsonc in VSCode.
Today i have check the AST of treesetter. My conclusion is that JSON with comment is not valid JSON but a valid JSON5
very interesting. then how exactly does json allow comments, with or without .jsonc extension?
As far as i have gone tru this standard it does not. Its configured per LSP implentation how it treats them. Also on the other hand jsonc can be interperted differently as per context.
As far i know some game servers / server-sdks implement handling of "Content-Type: application/jsonc" as compressed file usually done with lz compression per URL/Base64 encoding.
And also only filextension i have managed to file information that it supports is .jsonc everything else is done at LSP level. So there is apparend mix and mash of standards in open world.
Ah, ok, so its more down to basically LSP and "intellisense" if you will.
as long as its inside the .vscode directory, the vscode configuration files with comments, its treats as normal JSON and ignores the warning.
package.json (used by npm/nodejs) doesn't seem to allow comments, and I haven't seen any with comments.
package.json (used by npm/nodejs) doesn't seem to allow comments, and I haven't seen any with comments.
Yes, those are following JSON spec, basically anything that JSON.parse and JSON.stringify can convert to and from string is following JSON spec and at the same time javascripts spec for object notation
yeah and that makes sense too.
At least in VSCode, unless its a VSCode configuration file such as settings.json, extensions.json, tasks.json, keybindings.json, launch.json file, any .json file with comments in it that does not have the extension .jsonc, VSCode will show linting and intellisense errors that says 'Comments are not permitted in JSON'. Rename the JSON file with comments in it to .jsonc and it will not complain about this.
We should be certain that in this case any generated, validated, etc JSON with comments gets the correct extension.
I don't know if other editors and IDE's treat json with comments this way or warn about it.