提交 7440cbd4 编写于 作者: S Sandeep Somavarapu

Fix #31277

上级 eb3b8ddc
......@@ -961,6 +961,9 @@ export function visit(text: string, visitor: JSONVisitor, options?: ParseOptions
}
onSeparator(',');
scanNext(); // consume comma
if (_scanner.getToken() === SyntaxKind.CloseBracketToken && allowTrailingComma) {
break;
}
} else if (needsComma) {
handleError(ParseErrorCode.CommaExpected, [], []);
}
......
......@@ -234,6 +234,7 @@ suite('JSON', () => {
assertValidParse('{ "hello": [] }', { hello: [] }, options);
assertValidParse('{ "hello": [], "world": {}, }', { hello: [], world: {} }, options);
assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }, options);
assertValidParse('{ "hello": [1,] }', { hello: [1] }, options);
assertInvalidParse('{ "hello": [], }', { hello: [] });
assertInvalidParse('{ "hello": [], "world": {}, }', { hello: [], world: {} });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册