Project

General

Profile

Actions

Feature #16502

closed

Add option :allow_trailing_comma to JSON#parse

Added by j.spanjers (Jan-Joost Spanjers) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:96788]

Description

Hello everyone,

I'd like to be able to parse JSON sources that contain trailing commas in arrays and/or objects.

For example,

> JSON.parse('[1,2,3,]')
JSON::ParserError: 416: unexpected token at ']'

I have created a pull request to add the option :allow_trailing_comma to JSON#parse:

> JSON.parse('[1,2,3,]', allow_trailing_comma: true)
[1, 2, 3]

I would kindly like to ask you to consider this patch for merging in Ruby core.

Regards,
Jan-Joost Spanjers

[1] https://github.com/ruby/ruby/pull/2831

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0