Skip to content
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

'//' in string still broken in version 0.6 #16

Closed
jeremysalwen opened this issue Jun 19, 2017 · 3 comments
Closed

'//' in string still broken in version 0.6 #16

jeremysalwen opened this issue Jun 19, 2017 · 3 comments

Comments

@jeremysalwen
Copy link

How to reproduce this bug:

commentjson.loads(commentjson.dumps('//'))

@mewalig
Copy link

mewalig commented May 7, 2019

The fundamental problem is that this library tries to use regex to strip comments, which can't be done (at least, not in a way that will properly handle all cases). It needs a proper parser to do this. After this discovery, I've decided instead to handle the problem by making a simple system call to a better json comment stripping executable-- there are many available such as https://github.com/douglascrockford/JSMin or https://github.com/sindresorhus/strip-json-comments-- and which took 13 lines of python to replace commentjson

@vaidik
Copy link
Owner

vaidik commented May 25, 2019

Yeah you are right. The right way to do this would be to build a parser for the features that commentjson provides. I have not been able to find enough time to do it.

For the solution that you have provided to get around this problem, that might just work if your need is to javascript style comments (if my understanding is correct).

@vaidik vaidik mentioned this issue Jul 7, 2019
@vaidik
Copy link
Owner

vaidik commented Jul 7, 2019

This is fixed. You can try the latest version of commentjson which addresses this and a lot of other unhandled cases like this.

@vaidik vaidik closed this as completed Jul 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants