improved error handling for invalid json files