I am using a SOAP API that returns XML but with JSON strings within the response envelope. For most of the API calls this has not been a problem but there is one that returns Javascript new Date
objects that is causing problems when using JSON.parse
. Here is a simplified example of the response I am getting.
"{\"History\":[ {\"Timestamp\":new Date(1380024020923)}]}"
When using JSON.parse
I get the following error.
JSON::ParserError: 399: unexpected token at '{"Timestamp":new Date(1380024020923)}]}'
Is there a nice way to parse this string or am I going to have to use some regex/string trickery? Has anyone come across this way of returning a date object and I would like to understand the advantage?