Check data type before accessing like a dict