I’m working on a Blackberry 5.2 browser app. I have some JavaScriptthat returns some JSON. I know JSON parsing isn’t supported on older Blackberry phones but have been able to use eval to get the job done.
However on the Blackberry Curve running 5.2 my eval statements throw an error. The error is
SyntaxError: Error in eval(): Expecting ‘;’ found ‘:’ …
The string that it is trying to parse is correct and clean.
The javascript looks like this…
request.open("POST", url, false);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.setRequestHeader("Accept", "text/json");
request.send(params);
return eval(request.responseText);
and the response that its trying to eval looks like this…
{
"Authenticated": true,
"StatusCode": "Success",
"InternalErrorId": null,
"AuthenticationToken": "PxjcYnjBLN21ZMcWrEzKi9LC3vdXehMVSegEbVz61aca52113",
"AuthenticationTokenExpiry": "/Date(1340734497405)/",
"SessionTimeoutMinutes": 240
}
Does anyone know what might be going on here and how to fix it?
When using
evalto parse JSON, you need to wrap the JSON in().