Project

General

Profile

Actions

Bug #13070

closed

Parsing JSON with `quirks_mode: false` parses as if it is `true` and does not warn me.

Added by josh.cheek (Josh Cheek) over 7 years ago. Updated over 7 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
[ruby-core:78828]

Description

Previously you could parse toplevel strings in JSON by setting quirks_mode to true

$ ruby -rjson -v -e 'p JSON.parse JSON.dump("a"), quirks_mode: true'
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
"a"

If you set it to false, it would not parse them

$ ruby -rjson -v -e 'p JSON.parse JSON.dump("a"), quirks_mode: false'
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
/Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/json/common.rb:156:in `parse': 784: unexpected token at '"a"' (JSON::ParserError)
	from /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/json/common.rb:156:in `parse'
	from -e:1:in `<main>'

In Ruby 2.4.0, it always parses them, no matter how I set quirks_mode, but it does not warn me that it is going to ignore my instruction to disallow this behaviour.

$ ruby -rjson -v -e 'p JSON.parse JSON.dump("a"), quirks_mode: true'
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
"a"

$ ruby -rjson -v -e 'p JSON.parse JSON.dump("a"), quirks_mode: false'
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
"a"

I think it should warn me as explicitly setting it to false implies that I rely on this behaviour (this was my case).

The changelog should probably also mention something about it, I didn't understand what had happened until I located the commit, looked up its references, realized the specification may have changed, and then checked the RFC.

Updated by hsbt (Hiroshi SHIBATA) over 7 years ago

  • Status changed from Open to Third Party's Issue

Can you request it to upstream repository ?

Actions

Also available in: Atom PDF

Like0
Like0