Proper way to catch exception from JSON.parse

Sometimes, stored json data as strings is broken. As good developer practice, all operations or function calls which can throw an exception, must by handled in try catch block.
try {
arr = JSON.parse('{}');
} catch (e) {
Logger.error('JSON parse error: {0}', e);
}

Leave a Reply

Back to Top