I need to use python to query a data repository to later export the result to php in order to make it available on the web. To do it I use:
print json.dumps(res)
where res is the output array. Unfortunately when I execute it I receive error:
python palina.py 70032
Traceback (most recent call last):
File "palina.py", line 17, in <module>
print json.dumps(res)
File "/usr/lib/python2.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 263, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 177, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <DateTime '20140128T10:00:00' at 7f82ee9a5f80> is not JSON serializable
What other way of exporting the array exists without the need to serialize it? Or else, does exist some better serialization tool not producing this error?
Thanks,