From python I am making a call to a remote API which returns data in a JSON format. I then parse the data using the json module with json.loads(). The problem I am having is with dates – the system I am calling returns the date formatted like the following:
/Date(1354011247940+0000)/
which json.parse just parses out as a string. How can I convert this to a python date time object?
Edit: unlike Convert JSON to Python object: how to handle DateTime conversion?, I have no control over the data being sent, so I can not simply change the format prior to serializing.
You should get unix timestamp with a regex from this date, then use datetime module to convert it to readable format:
UPD: note , that you also have milliseconds in this date, they will be truncated by this code