JSON

Joshua Kugler jkugler at bigfoot.com
Thu Dec 6 14:58:00 EST 2007


belred at gmail.com wrote:

> i tried a couple python json libraries. i used simplejson on the
> server and was using cjson on the client, but i ran into this issue.
> i'm now using simplejson on both sides, but i'm still interested in
> this issue.  did i do something wrong? is there a bug in one of the
> libraries? or something i don't understand about the json spec?
> 
> 
> i problem is the line where i call cjson.decode() below:
> 
>>>> import simplejson
>>>> import cjson
>>>>
>>>> sj = simplejson.dumps('http://server.com')
>>>> sj
> '"http:\\/\\/server.com"'
>>>> cj = cjson.encode('http://server.com')
>>>> cj
> '"http://server.com"'
>>>> simplejson.loads(cj)
> u'http://server.com'
>>>> cjson.decode(cj)
> 'http://server.com'
>>>> simplejson.loads(sj)
> u'http://server.com'
>>>> cjson.decode(sj)
> 'http:\\/\\/server.com'     # is this correct????

Known issue.  See:
http://blog.extracheese.org/2007/07/when-json-isnt-json.html

Neither project has fixed it it seems.  Not sure which is actually
the "correct" way to do it, but it would be nice if they would agree.

j





More information about the Python-list mailing list