diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index 042e0c863e5f262b600ce95efd91170bf169eda0..ffa75f460955c3d2baaa20daade1911ff618d802 100644 --- a/src/vs/base/common/json.ts +++ b/src/vs/base/common/json.ts @@ -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, [], []); } diff --git a/src/vs/base/test/common/json.test.ts b/src/vs/base/test/common/json.test.ts index 065becde00806623a615ba09d100e1b26f1a546e..2551f00fde3b58775fbb7363394a48ee386551cb 100644 --- a/src/vs/base/test/common/json.test.ts +++ b/src/vs/base/test/common/json.test.ts @@ -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: {} });