because it is possible that response is a list or number or even an string. in that scenario is is not null but also you can't call that with a get. you can first check it is a json or not.
isinstance(res, dict)