Added try-catch for JSON parsing errors

```JSON.parse``` fails in some browsers (e.g. old WebKit) so this should provide a fallback.