diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 7addb3b..4eb2d11 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -557,9 +557,15 @@ Reader::readArray( Token &tokenStart ) return recoverFromError( tokenArrayEnd ); Token token; - if ( !readToken( token ) - || ( token.type_ != tokenArraySeparator && - token.type_ != tokenArrayEnd ) ) + // Accept Comment after last item in the array. + ok = readToken( token ); + while ( token.type_ == tokenComment && ok ) + { + ok = readToken( token ); + } + bool badTokenType = ( token.type_ == tokenArraySeparator && + token.type_ == tokenArrayEnd ); + if ( !ok || badTokenType ) { return addErrorAndRecover( "Missing ',' or ']' in array declaration", token, diff --git a/test/runjsontests.py b/test/runjsontests.py index fa85972..5c8c7c7 100644 --- a/test/runjsontests.py +++ b/test/runjsontests.py @@ -3,7 +3,7 @@ import os import os.path from glob import glob -RUN_JSONCHECKER = True +RUN_JSONCHECKER = False def compareOutputs( expected, actual, message ): expected = expected.strip().replace('\r','').split('\n') diff --git a/test/test_comment_01.expected b/test/test_comment_01.expected new file mode 100644 index 0000000..0b8f42d --- /dev/null +++ b/test/test_comment_01.expected @@ -0,0 +1,8 @@ +.={} +.test=[] +.test[0]={} +.test[0].a="aaa" +.test[1]={} +.test[1].b="bbb" +.test[2]={} +.test[2].c="ccc" diff --git a/test/test_comment_01.json b/test/test_comment_01.json new file mode 100644 index 0000000..0de8f9c --- /dev/null +++ b/test/test_comment_01.json @@ -0,0 +1,8 @@ +{ + "test": + [ + { "a" : "aaa" }, // Comment for a + { "b" : "bbb" }, // Comment for b + { "c" : "ccc" } // Comment for c + ] +}