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

Updated by mame (Yusuke Endoh) over 4 years ago

  • Status changed from Open to Feedback

The json library has another upstream repository: https://github.com/flori/json

Could you please send a pull request to them?

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

mame (Yusuke Endoh) wrote:

The json library has another upstream repository: https://github.com/flori/json

Could you please send a pull request to them?

Thank you for your feedback. I have created a new pull request (https://github.com/flori/json/pull/401) upstream.

Updated by mame (Yusuke Endoh) over 4 years ago

  • Status changed from Feedback to Closed

Thanks! If the pull request is merged, it will be backported to ruby/ruby. So I close this ticket.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0