Merge pull request #3776 from ncpenke/fix-bug-skipping-unknown-fields

Fix bug skipping unknown fields
This commit is contained in:
Wouter van Oortmerssen 2016-02-22 13:38:14 -08:00
commit 959866b848
2 changed files with 8 additions and 1 deletions

View File

@ -1557,8 +1557,12 @@ CheckedError Parser::SkipJsonObject() {
for (;;) {
if ((!opts.strict_json || !fieldn) && Is('}')) break;
if (!Is(kTokenStringConstant))
if (!Is(kTokenStringConstant)) {
EXPECT(opts.strict_json ? kTokenStringConstant : kTokenIdentifier);
}
else {
NEXT();
}
EXPECT(':');
ECHECK(SkipAnyJsonValue());

View File

@ -830,10 +830,13 @@ void UnknownFieldsTest() {
TEST_EQ(parser.Parse("table T { str:string; i:int;}"
"root_type T;"
"{ str:\"test\","
"unknown_string:\"test\","
"\"unknown_string\":\"test\","
"unknown_int:10,"
"unknown_float:1.0,"
"unknown_array: [ 1, 2, 3, 4],"
"unknown_object: { i: 10 },"
"\"unknown_object\": { \"i\": 10 },"
"i:10}"), true);
std::string jsongen;