jsonvalidate icon indicating copy to clipboard operation
jsonvalidate copied to clipboard

Detect and reject trailing commas

Open richfitz opened this issue 6 years ago • 2 comments

They are not valid JSON and so should not be permitted. jsonlite doesn't care, and nor does passing them directly through to V8

richfitz avatar Aug 22 '19 12:08 richfitz

Can you let a little bit more clear? Has some example?

aismaniotto avatar Oct 25 '19 18:10 aismaniotto

Trailing commas in arrays or objects are valid JavaScript but not valid JSON. For example:

[1, 2, ]

and

{
  "a": 1,
  "b": 2,
}

are not valid json (https://jsonlint.com) but can be passed into jsonvalidate because it never actually parses inputs as json

richfitz avatar Oct 28 '19 08:10 richfitz