move JSON.parse into try/catch block