adding some guards for empty jsons (#359)