RyanMarcus / dirty-json

A parser for invalid JSON
GNU Affero General Public License v3.0
294 stars 30 forks source link

Trailing comma #21

Closed Diokuz closed 4 years ago

Diokuz commented 4 years ago

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, '')
)
RyanMarcus commented 4 years ago

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