Added a try catch around JSON.parse.