def as_json(self):
        """Return the proxy's properties in JSON format.

        :rtype: dict
        """
        info = {
            'host': self.host,
            'port': self.port,
            'geo': {
                'country': {'code': self._geo.code, 'name': self._geo.name},
                'region': {
                    'code': self._geo.region_code,
                    'name': self._geo.region_name,
                },
                'city': self._geo.city_name,
            },
            'types': [],
            'avg_resp_time': self.avg_resp_time,
            'error_rate': self.error_rate,
        }

        order = lambda tp_lvl: (len(tp_lvl[0]), tp_lvl[0][-1])  # noqa: 731
        for tp, lvl in sorted(self.types.items(), key=order):
            info['types'].append({'type': tp, 'level': lvl or ''})
        return info
Return the proxy's properties in JSON format.

        :rtype: dict