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

Diez B. Roggisch deets at nospam.web.de
Mon Jan 26 04:06:27 EST 2009


gert schrieb:
> On Jan 26, 12:40 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>>>> But all of this is not JSON.
>>> Yes it is, you just make it more python dictionary compatible :)
>> No, what you do is to make it more incompatible with other
>> json-implementations. Which defies the meaning of a standard.
>>
>> Besides, {foo : "bar"} is *not* python dictionary compatible, at least
>> not unless you defined foo beforehand, and then there is no guarantee
>> that foo is actually as string containing 'foo'.
>>
>>> What is this json person email address so I can ask that he makes a
>>> very small update on his site.
>> Go try your luck -http://www.json.org/
>>
>>> Besides if you can make lightweight versions of standards
>>> http://docs.python.org/library/xml.dom.minidom.html
>> minidom is a lightweight version of the DOM-API. But it reads and writes
>> standard-conform XML documents.
>>
>> The same applies for element-tree and lxml.
>>
>> So it does not serve as a counter-example.
> 
> yes it does because adding ' does not mean replacing " so it will
> still load standard json. Like every browser does and is exactly the
> same philosofie as

No. If minidom would accept XML-documents that contain newlines in 
attributes (which otherwise are forbidden), e.g.

<foo bar="some
text"/>

*that* would be like adding single-quote stringliterals to JSON.

This is about the *format*, not the API.

There are people who say something along the lines of "be strict when 
writing, and tolerant when reading" (the exact quote is different, but 
neither google:~site:mybrain nor any other have helped me here), so one 
could argue that reading JSON that is not standard-conform would be ok.

But IMHO that would increase the amount of interoperability-problems - 
because some people would *write* json that isn't standard-conform anymore.

Diez




More information about the Python-list mailing list