Friday, January 05, 2007

How to ensure_ascii=False when using JSON dumps()

simplejson is very well written, but there's a catch. If you're doing UTF-8, make sure you ensure_ascii=False whenever calling dumps(). I don't know what it is with it that it will give you funky \uSOMETHING sequences for every non-ascii byte, and although that may display
right in HTML/JS, you should want to keep raw UTF-8 for better interoperability (specially with other JSON parsers).

No comments: