Added error handling for missing JSON objects.