cJSON icon indicating copy to clipboard operation
cJSON copied to clipboard

support for comments

Open yueswing07 opened this issue 6 years ago • 4 comments

there is many situations need read configure file has annotation i have test the code

char *s = "{//aa \n \"list\":[{\"name\":\"22xiao hong\",\"age\":10},{\"name\":\"33hua hua\",\"age\":\"11\"}]}";  
    cJSON *root = cJSON_Parse(s);

parse return NULL

yueswing07 avatar Dec 19 '17 02:12 yueswing07

Yes, JSON is kind of bad for configuration files because of this. This is why I personally prefer YAML for that, although it requires a much more complex parser.

I can't currently support comments in cJSON, but once #177 is implemented, it could be added as a configuration option.

FSMaxB avatar Dec 19 '17 09:12 FSMaxB

As comments are not part of the JSON standard, this must be optional.

And if we’re listing ‘favourite configuration format that isn’t JSON’, mine is PSON – PostScript Object Notation (which does support comments!).

nemo20000 avatar Jul 23 '18 17:07 nemo20000

As comments are not part of the JSON standard, this must be optional.

This would not be enabled by default of course

FSMaxB avatar Jul 25 '18 06:07 FSMaxB

Has there been any update on this topic?

mateosss avatar Oct 19 '21 15:10 mateosss