{"action":"closed","issue":{"url":"https://api.github.com/repos/web2py/pydal/issues/112","labels_url":"https://api.github.com/repos/web2py/pydal/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/web2py/pydal/issues/112/comments","events_url":"https://api.github.com/repos/web2py/pydal/issues/112/events","html_url":"https://github.com/web2py/pydal/issues/112","id":64757561,"number":112,"title":"datetime not json serializable","user":{"login":"salomonderossi","id":361473,"avatar_url":"https://avatars.githubusercontent.com/u/361473?v=3","gravatar_id":"","url":"https://api.github.com/users/salomonderossi","html_url":"https://github.com/salomonderossi","followers_url":"https://api.github.com/users/salomonderossi/followers","following_url":"https://api.github.com/users/salomonderossi/following{/other_user}","gists_url":"https://api.github.com/users/salomonderossi/gists{/gist_id}","starred_url":"https://api.github.com/users/salomonderossi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salomonderossi/subscriptions","organizations_url":"https://api.github.com/users/salomonderossi/orgs","repos_url":"https://api.github.com/users/salomonderossi/repos","events_url":"https://api.github.com/users/salomonderossi/events{/privacy}","received_events_url":"https://api.github.com/users/salomonderossi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-27T12:56:33Z","updated_at":"2015-03-29T23:02:57Z","closed_at":"2015-03-29T23:02:57Z","body":"Datetime objects in the pyDLA are not json serializable. In a pevious version of web2py's DAL json serializion did work fine.\r\n\r\nI use Version 15.3 of pyDAL with python2.7 on Ubuntu 14.04.2 LTS.\r\n\r\nHere ist a small program which demonstrates the issue:\r\n```python\r\nfrom pydal import DAL, Field\r\nfrom datetime import datetime\r\n\r\ndb = DAL('sqlite://storage.db', folder=\"test_databases\")\r\ndb.define_table('test_table', Field('date_field', 'datetime'))\r\n\r\ndb.test_table.insert(date_field=datetime.now())\r\n\r\nrows = db().select(db.test_table.ALL)\r\nprint(rows.as_json())\r\n```\r\nWhich gives this output on my machine:\r\n```\r\nTraceback (most recent call last):\r\n  File \"db_text.py\", line 13, in <module>\r\n    print(rows.as_json())\r\n  File \"/usr/local/lib/python2.7/dist-packages/pydal/objects.py\", line 2741, in as_json\r\n    return json.dumps(items)\r\n  File \"/usr/lib/python2.7/json/__init__.py\", line 243, in dumps\r\n    return _default_encoder.encode(obj)\r\n  File \"/usr/lib/python2.7/json/encoder.py\", line 207, in encode\r\n    chunks = self.iterencode(o, _one_shot=True)\r\n  File \"/usr/lib/python2.7/json/encoder.py\", line 270, in iterencode\r\n    return _iterencode(o, 0)\r\n  File \"/usr/lib/python2.7/json/encoder.py\", line 184, in default\r\n    raise TypeError(repr(o) + \" is not JSON serializable\")\r\nTypeError: datetime.datetime(2015, 3, 27, 13, 37, 7) is not JSON serializable\r\n```\r\n\r\n"}}