vivkin/gason

gason doesn't parse comments

ChrisJefferson opened this issue · 2 comments

I realise that // and /* ... */ comments are both not part of JSON, but they commonly pop up. I feel it it fit's gason's aim to parse as best as possible to handle comments, and they would not hurt efficiency.

I am happy to knock up a patch for this, but wanted to check before I bothered if it would in principle be accepted. I would make no attempt at saving the comments or making them accessable, just skip straight on over them.

I don't think this is a good idea. Comments are not supported in text editors, other parser and spec. With this extensions writing the simple pretty-print program turned into not a simple task at all.

I can understand not wanting to pretty print the comments -- I was suggesting throwing them away entirely.

For my current use, I have written a "strip comments" function I can call on a buffer, which removes comments before I parse the JSON (this function just replaces the comments with spaces, so the buffer becomes valid JSON).