Hello, 

I'm having a problem when I try to convert a python dictionary into a json 
dictionary (*json.dumps(results, ensure_ascii=False)*).
Everything is ok, but when there is a date as a valure of the dictionary I 
get this error: datetime.date is not json serializable. I don't know how to 
solve this.

Here my code:

mysqldb = get_mysql_db() cursor = mysqldb.cursor()# SQL query
cursor.execute("SELECT titulo, url from content_medios")
# getting the name of columns
columns = [column[0] for column in cursor.description]
 
# creating the dictionary
results = []
for row in cursor.fetchall():
 results.append(dict(zip(columns, row)))

# converting from py to json
jsonarray = json.dumps(results, ensure_ascii=False)
return jsonarray

mysqldb.close()





Thank you in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/78d4f809-2a00-4bfb-8014-5cdeff4cf8e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to