This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author thinred
Recipients thinred
Date 2011-10-18.18:00:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hi there!
According to . The JSON object is either a list or a dictionary with other elements in it. However Python's implementation took liberty to parse also basic types, like integers, strings, floats, etc. For example:

>>> import json
>>> json.loads('42')
>>> json.dumps(3.141592)

It wouldn't be a problem if other implementations would adhere to this behavior, but this is not true. Take Ruby for example:

irb(main):007:0> require 'rubygems';
irb(main):008:0* require 'json';
irb(main):009:0* JSON.parse '42'
JSON::ParserError: 743: unexpected token at '42'
	from /var/lib/gems/1.8/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
	from /var/lib/gems/1.8/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
	from (irb):9
	from :0
irb(main):010:0> JSON.generate(3.141592)
JSON::GeneratorError: only generation of JSON objects or arrays allowed
	from /var/lib/gems/1.8/gems/json-1.6.1/lib/json/common.rb:216:in `generate'
	from /var/lib/gems/1.8/gems/json-1.6.1/lib/json/common.rb:216:in `generate'
	from (irb):10
	from :0

Also considers it an error.

I know this is not very important, but I've ran into this today when trying to parse JSON in Ruby which was produced in Python.

I've made a patch for that, but I still need to fix tests and there are many of them. I first would like to know if it is going to be fixed, then I will complete the patch.

Thanks for Python, anyway!

Date User Action Args
2011-10-18 18:00:32thinredsetrecipients: + thinred
2011-10-18 18:00:32thinredsetmessageid: <>
2011-10-18 18:00:31thinredlinkissue13212 messages
2011-10-18 18:00:31thinredcreate