tags:

views:

140

answers:

2

When I do json.dumps with a dictionary that maps strings to a list of unicodes, python raises a type error. Why does that not work?

A: 

Providing a small code sample that shows the error you are seeing would be very helpful.

+1  A: 

Works fine for me in Python 2.6 (and identically in 3.1, without the u prefix on the value):

>>> import json
>>> d={'a': u'fél'}
>>> json.dumps(d)
'{"a": "f\\u00e9l"}'

Can you please reproduce and post (by editing your answer, so you can format it properly) the tiniest bit of code that gives you the problem?

Alex Martelli