-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Support for trailing commas #1787
Comments
This has been discussed before (eg, #376 ) and in the README (https://github.com/nlohmann/json#comments-in-json). Although these are both about comment support in JSON, the same rationale applies to trailing-comments. |
So to rephrase that, will there be support for JSON5? |
Not in this library. I currently do not have the time to invest in JSON5. |
Thanks, do you know any C++ Json library that supports it? |
No, but I hardly have heard of anyone using JSON5 for that matter. I think going to YAML could be a better idea, as it has wider support. |
Hi!
Did you mean trailing-commas ? Because json comments actually are supported so that would mean there is no more reason to not support trailing-commas, right ? |
Both a trailing comma and a comment are syntax errors in JSON. But I understand the rationale of having comments in JSON, so I eventually added support for them. I still lack the understanding why trailing commas should be supported, though. |
|
Just hit this issue myself, but wanted to add that I found the "ignore comments" flag to parse() to be a pretty simple solution for balancing that interoperability/usability situation. Seems like "ignore trailing commas" could be a similar nice-to-have. Might even make sense as additional functionality behind the current "ignore" flag, as most callers of that signature are probably okay with interop tradeoffs. |
It looks that the current parse function throws an out_of_range exception when a trailing comma is detected e.g.:
The above works fine if the comma after "value2" is removed.
I know that the trailing comma is not allowed in the original json specification but I think that it is going to be allowed in future ones and it seems to me an unnecessary inconvenience.
Would you consider allowing this in your library?
The text was updated successfully, but these errors were encountered: