G
gert
raise ValueError(errmsg("Expecting property name", s, end))
http://docs.python.org/library/json.html
What am I doing wrong ?
http://docs.python.org/library/json.html
What am I doing wrong ?
gert said:raise ValueError(errmsg("Expecting property name", s, end))
http://docs.python.org/library/json.html
What am I doing wrong ?
raise ValueError(errmsg("Expecting property name", s, end))http://docs.python.org/library/json.html
What am I doing wrong ?
raise ValueError(errmsg("Expecting property name", s, end))
http://docs.python.org/library/json.html
What am I doing wrong ?
try thishttp://docs.python.org/library/json.html
What am I doing wrong ?
try this
v = json.loads('{"test":"test"}')
JSON doesn't support single quotes, only double quotes.
So what? That's python deciding to print strings using single-quotes.
That has nothing to do with JSON.
The important part is this:
 >>> json.dumps(json.loads('{"test":"test"}'))
'{"test": "test"}'
It's not hard, but it's not standard-conform.
Most browsers even accept something like this:
{foo : "bar"}
But all of this is not JSON.
Yes it is, you just make it more python dictionary compatible
What is this json person email address so I can ask that he makes a
very small update on his site.
Besides if you can make lightweight versions of standards
http://docs.python.org/library/xml.dom.minidom.html
You can defenatly add lightweight quotes to json.
OK, playing the devil's advocate here: Doesn't practicality beat purity?It's not hard, but it's not standard-conform.
Yes it is, you just make it more python dictionary compatible
What is this json person email address so I can ask that he makes a
very small update on his site.
Besides if you can make lightweight versions of standards
http://docs.python.org/library/xml.dom.minidom.html
You can defenatly add lightweight quotes to json.
It's not practical to expect a standard to be rewritten to conform withAndreas said:OK, playing the devil's advocate here: Doesn't practicality beat purity?
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'.
Go try your luck -http://www.json.org/
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.
But as gert says, the standard is "broken" by many many browsersIt'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.
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.
gert said:the funny part is when you print(v) you get
{'test': 'test'}
Single quotes works in every browser that support json so i
recommended python should support it too, besides it looks much
cleaner
{'test': 'test'}
{"test": "test"}
It can not be that hard to support both notation can it ?
Matt said:gert said:the funny part is when you print(v) you get
{'test': 'test'}
Single quotes works in every browser that support json so i
recommended python should support it too, besides it looks much
cleaner
{'test': 'test'}
{"test": "test"}
It can not be that hard to support both notation can it ?
There's a difference between JavaScript source code and JSON. AFAICT
from the source [1], Mozilla's JSON parser doesn't accept single quotes.
[1] <http://mxr.mozilla.org/mozilla-central/source/js/src/json.cpp>
Andreas Waldenburger said:But as gert says, the standard is "broken" by many many browsers
already
Diez said:It's not hard, but it's not standard-conform.
Most browsers even accept something like this:
{foo : "bar"}
But all of this is not JSON.
gert said: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
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)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.