diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 8cfd04bdc..87b999d70 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -3189,6 +3189,9 @@ CheckedError Parser::ParseRoot(const char *source, const char **include_paths, } } } + // Parse JSON object only if the scheme has been parsed. + if (token_ == '{') { ECHECK(DoParseJson()); } + EXPECT(kTokenEof); return NoError(); } @@ -3308,7 +3311,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths, } else if (IsIdent("namespace")) { ECHECK(ParseNamespace()); } else if (token_ == '{') { - ECHECK(DoParseJson()); + return NoError(); } else if (IsIdent("enum")) { ECHECK(ParseEnum(false, nullptr)); } else if (IsIdent("union")) {