Add error handling for JSON parsing.