datetime.datetime is not JSON serializable : <p>I have a class in Python for retrieving all the columns in a table and return a JSON with this data.</p>

<p>The problem is at least one of those columns is a datetime and I can't seem to understand how to serialize the columns so I can generate a valid JSON.</p>

<p>My class is as follows:</p>

<pre><code>class GetTodos(Resource):
    def get(self):
        con = cx_Oracle.connect('brunojs/bdpf5@127.0.0.1/orcl')
        cur = con.cursor()
        cur.execute("select * from organite_repository")
        r = [dict((cur.description[i][0], value) \
                for i, value in enumerate(row)) for row in cur.fetchall()]
        cur.connection.close()
        return (r[0] if r else None) if None else r 
</code></pre>

<p>Any hints on this?</p>
