dropbox / json11

A tiny JSON library for C++11.
MIT License
2.54k stars 613 forks source link

about the comments #101

Closed mfzhu7 closed 7 years ago

mfzhu7 commented 7 years ago

hey, i got confused when i read the code about the comment part.first:when the comment is start with "//",why it must end with "/n"? is only one line comment startwith "//" is not allowed? second: for the multi line comment, when the end is "*/" ,why this situation is wrong?

thanks you for your explanation

artwyman commented 7 years ago

I'm not sure I understand your question. The intent is to allow comments inside of a JSON string, if they following C++ comment syntax (including single-line and multi-line variants).

mfzhu7 commented 7 years ago

what makes confused is : in file json11.cpp line 403.when you get the string start with /, then you move on unitl got the /。why if (i == str.size()); return fail?

artwyman commented 7 years ago

That case of an unterminated multi-line comment is correct. Multiline comments need to be terminated with */ before the end of the input. However, the corresponding case for single-line comments starting with // is a bug. Those can appear at the end of input and it should be valid.

It looks like the comment tests in test.cpp don't cover all cases, and also aren't self-checking (they print input, but don't assert). I'm going to take a pass at improving them, along with improving hte parser's handling of end-of-input and failures in comments.