formats/json/m_json_reader.c
/*! Eat comments.
 * Supports C and C++ style / * and / / (no spaces between the two characters) comments.
 *
 * There is debate whether comments are really allowed by JSON. The spec doesn't support them
 * but the creator of JSON (who wrote the spec) Douglas Crockford says:
 * "JSON does not have comments. A JSON encoder MUST NOT output comments.
 * A JSON decoder MAY accept and ignore comments." (http://tech.groups.yahoo.com/group/json/message/152)
 *
 * Since JSON is "JavaScript Object Notation" we only support comments supported by Javascript.
 */
Eat comments.
Supports C and C++ style / * and / / (no spaces between the two characters) comments.

There is debate whether comments are really allowed by JSON. The spec doesn't support them
but the creator of JSON (who wrote the spec) Douglas Crockford says:
"JSON does not have comments. A JSON encoder MUST NOT output comments.
A JSON decoder MAY accept and ignore comments."

Since JSON is "JavaScript Object Notation" we only support comments supported by Javascript.
Eat comments . Supports C and C ++ style / * and / / ( no spaces between the two characters ) comments . There is debate whether comments are really allowed by JSON . The spec doesn ' t support them but the creator of JSON ( who wrote the spec ) Douglas Crockford says : " JSON does not have comments . A JSON encoder MUST NOT output comments . A JSON decoder MAY accept and ignore comments . " Since JSON is " JavaScript Object Notation " we only support comments supported by Javascript .
static M_bool M_json_eat_comment(M_parser_t *parser, M_uint32 flags, M_json_error_t *error)
{
	const unsigned char *s;
	M_bool               isblock = M_FALSE;;
	if (flags & M_JSON_READER_DISALLOW_COMMENTS)
		return M_TRUE;
	s = M_parser_peek(parser);
	if (M_parser_len(parser) < 2 || *s != '/')
		return M_TRUE;
	isblock = (*(s+1) == '*');
	if (isblock) {
		M_parser_mark(parser);
		M_parser_consume(parser, 2);
		if (!M_parser_consume_until(parser, (const unsigned char *)"*/", 2, M_TRUE)) {
			M_parser_mark_rewind(parser);
			*error = M_JSON_ERROR_MISSING_COMMENT_CLOSE;
			return M_FALSE;
		}
		M_parser_mark_clear(parser);
	} else if (*(s+1) == '/') {
		M_parser_consume_eol(parser);
	} else {
		*error = M_JSON_ERROR_UNEXPECTED_COMMENT_START;
		return M_FALSE;
	}
	return M_TRUE;
}
static M_bool M_json_eat_comment ( M_parser_t * parser , M_uint32 flags , M_json_error_t * error ) { const unsigned char * s ; M_bool isblock = M_FALSE ; ; if ( flags & M_JSON_READER_DISALLOW_COMMENTS ) return M_TRUE ; s = M_parser_peek ( parser ) ; if ( M_parser_len ( parser ) < 2 || * s != ' ' ) return M_TRUE ; isblock = ( * ( s + 1 ) == ' ' ) ; if ( isblock ) { M_parser_mark ( parser ) ; M_parser_consume ( parser , 2 ) ; if ( ! M_parser_consume_until ( parser , ( const unsigned char * ) " " , 2 , M_TRUE ) ) { M_parser_mark_rewind ( parser ) ; * error = M_JSON_ERROR_MISSING_COMMENT_CLOSE ; return M_FALSE ; } M_parser_mark_clear ( parser ) ; } else if ( * ( s + 1 ) == ' ' ) { M_parser_consume_eol ( parser ) ; } else { * error = M_JSON_ERROR_UNEXPECTED_COMMENT_START ; return M_FALSE ; } return M_TRUE ; }
Eat comments.
Eat comments .
/* Check if we have a comment. */ /* Determine if the comment is a block or line comment. */ /* Move past the opening of the comment */