-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Add ignore_trailing_commas option #4609
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
Add ignore_trailing_commas option #4609
Conversation
7c7adb3 to
ed1d330
Compare
31dcd16 to
e0dfccd
Compare
|
Maybe the documentation should somewhere also mention JWCC - it's good when things have a name. |
|
How do you think about combining the two options We can name the new combined option I think that any user who choose to allow comments will not mind allowing trailing commas, and it is hard to imagine a use case where one must be enabled and the other disabled. Regarding compatibility issues, this will not affect the serialization results, nor will it refuse to accept inputs accepted by previous versions. It will just accept some inputs that would not have been accepted before. This solution is also conducive to adding new features in the future. But for me this is not important, because I only support adding two features of JWCC. |
Can I declare that this library would never add extensions (such as allow |
Never say never... |
No, please leave it as is as it would change the behavior of existing code. Just like with the |
|
I combine the documentation about comments and trailing commas. Any more suggestions? |
No, please leave it as is. We may combine this in the future, but right now, I would like the URLs of the documentation to not change (https://www.w3.org/Provider/Style/URI). |
Could we just add a redirect rule to redirect_maps:
'api/basic_json/operator_gtgt.md': api/operator_gtgt.md
'api/basic_json/operator_ltlt.md': api/operator_ltlt.md
'api/basic_json/operator_literal_json.md': api/operator_literal_json.md
'api/basic_json/operator_literal_json_pointer.md': api/operator_literal_json_pointer.md
'api/json_pointer/operator_string.md': api/json_pointer/operator_string_t.md
'home/code_of_conduct.md': community/code_of_conduct.md
+ 'features/comments.md': features/comments_and_trailing_commas.md |
Yes, but please revert anyway. |
9cc35a4 to
36c5061
Compare
barroca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice new feature. :)
|
Hi! Is there any ETA for this PR to be merged? Are any of the requested changes still outstanding? I'm very interested in using this feature in a work project (it would make it much easier for us to create a nice human-readable default configuration file). Thanks for everyone's work on this library! |
7fb2ff2 to
67d04bc
Compare
67d04bc to
f8259fd
Compare
+1 |
|
Hi there, we would also need this. Is there an ETA? |
|
@nlohmann are you ok with the changes now? |
nlohmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An entry like "- Added ignore_trailing_commas in version 3.12.1." is missing in the "Version history" section of docs/mkdocs/docs/api/basic_json/sax_parse.md.
Yes, I just added a minor remark on the documentation. |
Added examples and modified the corresponding documents and unit tests. Co-authored-by: Niels Lohmann <[email protected]> Signed-off-by: chirsz-ever <[email protected]>
f8259fd to
481985f
Compare
Done. |
nlohmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
|
Thanks! |
This PR adds
ignore_trailing_commasargument to thedetail::parserconstructor,basic_json::accept,basic_json::parseandbasic_json::sax_parse.Why
In short: I totally agree with the JWCC extension.
After adding this, we can parse tsconfig.json, which allow trailing commas. (By the way, VSCode has a
allowTrailingCommasoption in its json schema configuration).More projects would be attracted to use this library, e.g. R2Northstar/NorthstarLauncher#715.
Related issues: #1429 #1787 #1734
Detail Changes
ignore_trailing_commasargument to thedetail::parserconstructor,basic_json::accept,basic_json::parseandbasic_json::sax_parse.,to non-empty objects and arrays for testing.Pull request checklist
make amalgamate.