error handling in JSON convert