RyanMarcus / dirty-json

A parser for invalid JSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trailing comma

Diokuz opened this issue · comments

Failed to parse:

const dJSON = require('dirty-json')

const x = dJSON.parse(`{
  text: 'foo bar',
}`
)

Succeed:

const dJSON = require('dirty-json')

const x = dJSON.parse(`{
  text: 'foo bar',
}`.replace(/,\s*\}/g, '')
)

Oops, looks like I got this case for lists but missed it for objects.