Closed jeremysalwen closed 5 years ago
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
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).
How to reproduce this bug:
commentjson.loads(commentjson.dumps('//'))