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

gert gert.cuykens at gmail.com
Sun Jan 25 18:08:04 EST 2009


On Jan 25, 11:51 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> gert schrieb:
>
> > On Jan 25, 11:16 pm, Дамјан Георгиевски <gdam... at gmail.com> wrote:
> >>> raise ValueError(errmsg("Expecting property name", s, end))
> >>>http://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.
>
> > the funny part is when you print(v) you get
> > {'test': 'test'}
>
> 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"}'
>
> > 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 ?
>
> 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.




More information about the Python-list mailing list