Return a json string that can also  be used as a key.

    The JSON is explicitly unambiguous in the item order
    entries (dictionaries are not ordered usually)
    Otherwise it is valid JSON
12311
def serialize_identity(self, identity):
    
    section, check, iterargs = identity
    values = map(
        # separators are without space, which is the default in JavaScript;
        # just in case we need to make these keys in JS.
        partial(json.dumps, separators=(',', ':'))
        # iterargs are sorted, because it doesn't matter for the result
        # but it gives more predictable keys.
        # Though, arguably, the order generated by the profile is also good
        # and conveys insights on how the order came to be (clustering of
        # iterargs). `sorted(iterargs)` however is more robust over time,
        # the keys will be the same, even if the sorting order changes.
      , [str(section), check.id, sorted(iterargs)]
    )
    return '{{"section":{},"check":{},"iterargs":{}}}'.format(*values)
1061734
def to_json(self):
        

        web_resp = collections.OrderedDict()

        web_resp['status_code'] = self.status_code
        web_resp['status_text'] = dict(HTTP_CODES).get(self.status_code)
        web_resp['data'] = self.data if self.data is not None else {}
        web_resp['errors'] = self.errors or []

        return web_resp
597949
def json(self, with_candidates=False):
        

        def _json_or_none(obj):
            return None if obj is None else obj.json()

        data = {
            "status": self.status,
            "method_name": self.method_name,
            "interval": self.interval,
            "model": _json_or_none(self.model),
            "r_squared_adj": _noneify(self.r_squared_adj),
            "warnings": [w.json() for w in self.warnings],
            "metadata": self.metadata,
            "settings": self.settings,
            "totals_metrics": _json_or_none(self.totals_metrics),
            "avgs_metrics": _json_or_none(self.avgs_metrics),
            "candidates": None,
        }
        if with_candidates:
            data["candidates"] = [candidate.json() for candidate in self.candidates]
        return data
1294110
def dict(self):
        

        d = {p.key: getattr(self, p.key) for p in self.__mapper__.attrs if p.key not in ('data')}

        d['secret'] = 'not available'

        if self.secret_password:
            try:
                d['secret'] = self.decrypt_secret()
            except AccountDecryptionError:
                pass

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return {k: v for k, v in d.items()}
86773
def json(self, var, default=NOTSET):
        
        return self.get_value(var, cast=json.loads, default=default)
872799
def _as_dict(self) -> Dict[str, JsonTypes]:
        
        return {k: v._as_dict if isinstance(v, JsonObj) else
                   self.__as_list(v) if isinstance(v, list) else
                   v for k, v in self.__dict__.items()}
69233
def to_json(self):
        
        data = {}
        for k, v in self.__dict__.items():
            if not k.startswith('_'):
                # values not serializable, should be converted to strings
                if isinstance(v, datetime):
                    v = utils.datetime_to_string(v)
                elif isinstance(v, date):
                    v = utils.date_to_string(v)
                elif isinstance(v, uuid.UUID):
                    v = str(v)
                elif isinstance(v, Decimal):
                    v = str(v)
                data[k] = v
        return data
992154
def get(self, key, default=None):
        
        if key in self:
            return self.items_dict[self.__dict__[str(type(key))][key]]
        else:
            return default
290355
def _create_json(self):
        
        data_json = {
            'name': self.name,
            'email': self.email,
            'password': self.password,
            'admin': self.admin,
            "profileUpdatable": self.profileUpdatable,
            "internalPasswordDisabled": self.internalPasswordDisabled,
            "groups": self._groups,
        }
        return data_json
850938
def to_json(self, lev=0, indent=None):
        
        if lev:
            return self.to_dict(lev + 1)
        else:
            return json.dumps(self.to_dict(1), indent=indent)
591990
def to_json(self):
        
        res = dict()
        res['Count'] = self.count
        res['Messages'] = self.messages
        res['ForcedState'] = self.forced
        res['ForcedKeyboard'] = self.keyboard
        res['Entities'] = list()
        for item in self.entities:
            res['Entities'].append(item.to_json())
        res['ForcedMessage'] = self.forced_message
        return res
925080
def json_data(self):
        
        def stringify_keys(d):
            if not isinstance(d, dict):
                return d
            return dict((str(k), stringify_keys(v)) for k, v in d.items())
        data = self.make_data()
        json_data = json.dumps(stringify_keys(data))
        return json_data
1062855
def json_dumps(self, data, **options):
        
        params = {'sort_keys': True, 'indent': 2}
        params.update(options)
        # This code is based off django's built in JSON serializer
        if json.__version__.split('.') >= ['2', '1', '3']:
            # Use JS strings to represent Python Decimal instances (ticket #16850)
            params.update({'use_decimal': False})
        return json.dumps(data, cls=DjangoJSONEncoder, **params)
1261013
def to_json(self):
    
    return {self.BLOB_KEY_PARAM: self._blob_key,
            self.START_INDEX_PARAM: self._start_index,
            self.END_INDEX_PARAM: self._end_index}
732472
def deunicode(item):
    
    if item is None:
        return None
    if isinstance(item, str):
        return item
    if isinstance(item, six.text_type):
        return item.encode('utf-8')
    if isinstance(item, dict):
        return {
            deunicode(key): deunicode(value)
            for (key, value) in item.items()
        }
    if isinstance(item, list):
        return [deunicode(x) for x in item]
    raise TypeError('Unhandled item type: {!r}'.format(item))
767746
def json(self):
        
        try:
            return self._json
        except AttributeError:
            try:
                self._json = json.loads(self.text)
                return self._json
            except:  # noqa e722
                raise RequestInvalidJSON("Invalid JSON received")
850021
def AsJsonString(self):
        
        return json.dumps(self.AsDict(dt=False), sort_keys=True)