Bug #10143

JSON module does not conform to RFC 7159

Added by Chibi Magic 7 months ago. Updated 4 months ago.

[ruby-core:64406]
Status:Third Party's Issue
Priority:Low
Assignee:Yui NARUSE
ruby -v:ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] Backport:2.0.0: UNKNOWN, 2.1: UNKNOWN

Description

From RFC 7159: http://tools.ietf.org/html/rfc7159
~~~
A JSON text is a serialized value. Note that certain previous
specifications of JSON constrained a JSON text to be an object or an
array.
~~~

This means that the following should be valid:
JSON.parse('1')
JSON.parse('this is a string')

However, they each currently return a JSON::ParserError:
A JSON text must at least contain two octets!
or
757: unexpected token at 'this is a string'

History

#1 Updated by Yui NARUSE 7 months ago

  • Target version set to next minor
  • Priority changed from Normal to Low
  • Assignee set to Yui NARUSE
  • Status changed from Open to Assigned
  • Category set to ext

#2 Updated by Jack Thorne 4 months ago

I cannot find another linter that would accept this as input. example: http://www.jslint.com
I can however see that there are more examples of values in the RFC http://tools.ietf.org/html/rfc7159#section-13.
If I am reading this correctly strings, numbers and booleans can be passed.

So all the following should be valid.
JSON.parse('1')
JSON.parse('this is a string')
JSON.parse(42)
JSON.parse(true)

#3 Updated by Yui NARUSE 4 months ago

  • Status changed from Assigned to Third Party's Issue

Also available in: Atom PDF