From 7440cbd4a2c316c6be58b4a0821550c86c6d54f7 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 27 Nov 2017 12:13:07 +0100 Subject: [PATCH] Fix #31277 --- src/vs/base/common/json.ts | 3 +++ src/vs/base/test/common/json.test.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index 042e0c863e5..ffa75f46095 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 065becde008..2551f00fde3 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: {} }); -- GitLab