-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
How do I put comment in JSON now? #2567
Comments
|
I think we could go with something like reserving underscore prefixed keys to be always comments - thoughts @Geod24 ? On the other hand we could also start supporting regular JS-style comments. However right now there are most likely development apps reading dub.json files manually to look for certain keys, so we wouldn't want to break those. To properly read what the DUB recipe does you should rather use Personally I think JS-style comments would be the most intuitive and easy to understand form inside JSON files. However I think the slowness of |
Yes, that's indeed what happens here, in addition. The comments here are intended for people copying the recipe from examples. |
|
I think underscores (or some other prefix) makes sense as a stopgap measure. As a long term solution, either JSON5 or YAML ? :) |
|
Can we add |
|
I would also want a "comment" key to be accepted. :) this can be nice semantic information for displaying dub.json also eventually |
|
One of the issue I have with |
|
So if I have more than one comment in a json, i have to call them |
|
I need to see, the error currently comes from the YAML parser, it's not something we control. But no, we're just going to flat out ignore |
|
Wouldn't it be possible to also flat out ignore |
|
Personally I can live with |
|
Why not use just |
|
Many reasons:
|
|
I think at some point Dub started using a YAML parser for But this also means you can now just use YAML syntax, including comments. Right? |
|
Well YAML is not a superset, since multiple keys with same name do not parse. The problem is we have a build tool (necessary to do Universal Builds on macOS and much other stuff) that read some keys from This changes pushed me to have the build tool include the (relatively complicated and less maintained) |
|
I think Dub should be the only software parsing Dub configuration files. Trying to do it any other way is where the problems start. If we start saying "we can't change dub.sdl/dub.json because it will break p0nce's parser", it will be the start of the end of days :) If it can't use |
|
there are a bunch of tools that parse dub.json, although the recommended approach to parse the dub.json file (and dub.sdl) is by parsing the output of |
|
Editors like IntelliJ parse and build a tree that you can modify for JSON files, including for dub.json. We shouldn't be introducing a new syntax feature for documented file formats like JSON. |
|
OK, but therefore we should not have made Dub use a YAML parser for |
|
@CyberShadow first of all, that's a bit much, it was said when SDLang was introduced that JSON would always be supported. Anyway, because the issue is small, I think a good way would just be an escape hatch like I'm a bit wary for frequently duplicated keys, like "versions". Need to test that. (EDIT: it's better now, multiple "versions" was silently failing in the first place) EDIT: Other than that, the new YAML parser does manages the schema internally! It is well worth it. |
|
Former DUB doesn't warn on multiple "versions" keys, but the new DUB does. And the new one is more correct, since the second key would silently erase the first in former DUB. So this dupe key case was much improved by the move to single-keys. "versions": ["a"],
"versions": ["b"],New message:
|
System information
Bug Description
DUB complains about non-existent keys in the schema, even those called
"comment".But those JSON comments are there to avoid mistakes for the users of the project.
How to reproduce?
Build this project => https://github.com/AuburnSounds/Dplug/tree/master/examples/ms-encode who has a "comment-stuff" key.
Keys named just "comment" could be in the schema, and ignored.
Expected Behavior
A special way to write comment in dub.json, like we were advised to do. I don't want to go
.sdl, it would disrupt users more.Logs
The text was updated successfully, but these errors were encountered: