v = json.loads("{'test':'test'}")

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Jan 25 20:07:12 EST 2009


On Sun, 25 Jan 2009 19:04:44 -0500, Steve Holden wrote:

> Andreas Waldenburger wrote:
>> On Sun, 25 Jan 2009 23:51:41 +0100 "Diez B. Roggisch"
>> <deets at nospam.web.de> wrote:
>> 
>>> gert schrieb:
>>>> {'test': 'test'}
>>>> {"test": "test"}
>>>>
>>>> It can not be that hard to support both notation can it ?
>>> It's not hard, but it's not standard-conform.
>>>
>> OK, playing the devil's advocate here: Doesn't practicality beat
>> purity?
>> 
> It's not practical to expect a standard to be rewritten to conform with
> the ideas of one individual, as well as all the implementations of that
> standard.


Supposedly "every browser" (what, all of them?) already support a de 
facto extension to the JSON standard, allowing more flexible quoting. In 
an ideal world, yes the standard should change to conform to what "all 
browsers" do, since what they do is sensible. In my opinion, Python's 
handling of quotes simply is The Right Way To Do It.

But more realistically, I think a more attainable solution will be for 
json.loads() to give a better error message than "Expecting property 
name" when you use the wrong quotes.


-- 
Steven



More information about the Python-list mailing list