converting JSON to string

Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Sat Jan 12 09:58:21 CET 2008


-On [20080112 08:38], Gowri (gowricp at gmail.com) wrote:
>Actually, I have one other problem after all this. I see that if I try
>to construct JSON output as above, it is of the form
>[{'isbn': u'1-56592-724-9', 'title': u'The Cathedral & the Bazaar'},
>{'isbn': u'1-56592-051-1', 'title': u'Making TeX Work'}]
>The extra 'u' seems to causing syntax error in JavaScript which is not
>able to parse this response string. Any idea how I can fix this?

JSON does not support Unicode in the sense of allowing raw Unicode codepoints.
Instead JSON uses a \uNNNN scheme to encode Unicode characters (a bit flawed
to limit it to four hexadecimal digits though, it leaves the whole CJK Unified
Ideographs Extension B out of scope.).

I use simplejson along with lxml/ElementTree for my JSON<>XML needs.

-- 
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Any road leads to the end of the world...



More information about the Python-list mailing list