Load a :class:`ApplicationResponse` from a dictionary or string (that
        will be parsed as json).
326691
def load_from_json(data):
        
        if isinstance(data, str):
            data = json.loads(data)
        items = [Item.load_from_json(a) for a in data['items']] if data['items'] is not None else []
        return ApplicationResponse(
            data['title'], data['uri'], data['service_url'],
            data['success'], data['has_references'], data['count'], items
        )
1183964
def load_json(cls, data, default_rule=None, raise_error=False):
        """"""

        rules = {k: _parser.parse_rule(v, raise_error)
                 for k, v in json.loads(data).items()}

        return cls(rules, default_rule)
199004
def json(
    body,
    status=200,
    headers=None,
    content_type="application/json",
    dumps=json_dumps,
    **kwargs
):
    
    return HTTPResponse(
        dumps(body, **kwargs),
        headers=headers,
        status=status,
        content_type=content_type,
    )
607241
def resp_json(resp):
    
    if isinstance(resp, flask.Response):
        if 400 <= resp.status_code < 600:
            msg = resp.status
            try:
                result = loads(resp.data.decode("utf-8"))
                if isinstance(result, str):
                    msg = "%s, %s" % (resp.status, result)
                else:
                    msg = "%s %s, %s" % (
                        resp.status_code, result["error"], result["message"])
            except Exception:
                pass
            raise requests.HTTPError(msg, response=resp)
        else:
            return loads(resp.data.decode("utf-8"))
    else:
        try:
            resp.raise_for_status()
        except requests.HTTPError as ex:
            # the response may contains {"error": "", "message": ""}
            # append error and message to exception if possible
            try:
                result = resp.json()
                ex.args += (result["error"], result["message"])
            except (ValueError, KeyError):
                pass
            raise
        return resp.json()
943056
def str_to_application_class(self, an_app_key):
        """"""
        try:
            app_class = str_to_python_object(self.apps[an_app_key])
        except KeyError:
            app_class = str_to_python_object(an_app_key)
        try:
            self.application_defaults = DotDict(
                app_class.get_application_defaults()
            )
        except AttributeError:
            # no get_application_defaults, skip this step
            pass
        return app_class
707912
def json_response(data, status=200, serializer=None):
    
    return HttpResponse(json.dumps(data, default=serializer),
                        status=status,
                        content_type='application/json; charset=UTF-8')
824125
def loads( source ):
    
    source = source.strip()
    assert source.startswith( '{' )
    assert source.endswith( '}' )
    source = source[1:-1]
    result = {}
    for match in attr.finditer( source ):
        key = match.group('key')
        if match.group( 'list' ) is not None:
            value = [ 
                int(x) 
                for x in match.group( 'list' ).strip().replace(',',' ').split() 
            ]
        elif match.group( 'int' ) is not None:
            value = int( match.group( 'int' ))
        elif match.group( 'string' ) is not None:
            def deescape( match ):
                return unichr( int( match.group(0)[2:], 16 ))
            value = match.group('string').decode( 'utf-8' )
            value = escape.sub( 
                deescape,
                value,
            )
            value = simple_escape.sub(
                lambda x: x.group(1),
                value,
            )
        else:
            raise RuntimeError( "Matched something we don't know how to process:", match.groupdict() )
        result[key] = value
    return result
1275461
def load_from_json(data):
        
        if isinstance(data, str):
            data = json.loads(data)
        return Item(data['title'], data['uri'])
1216215
def parse_response(response):
    
    if response.headers.get('Content-Type', JSON_TYPE).startswith(JSON_TYPE):
        return ResponseObject(json.loads(response.body))
    else:
        return response.body
213217
def load(fp, encoding=None, cls=JSONTreeDecoder, object_hook=None,
         parse_float=None, parse_int=None, parse_constant=None,
         object_pairs_hook=None, **kargs):
    
    return json.load(fp, encoding, cls, object_hook,
         parse_float, parse_int, parse_constant,
         object_pairs_hook, **kargs)
554601
def _load_response(response):
    '''
    
    '''

    try:
        data = salt.utils.json.loads(response.text)
    except ValueError:
        data = response.text

    ret = {'code': response.status_code, 'content': data}

    return ret
84233
def _get_json_obj(self, endpoint, query, is_post=False):
        
        response = self._get_response(endpoint, query, is_post=is_post)
        content = response.text
        try:
            return loads(content)
        except ValueError:
            raise Exception('Could not decode content to JSON:\n%s'
                            % self.__class__.__name__, content)
444350
def json_loads(cls, s, **kwargs):
        
        if 'cls' not in kwargs:
            kwargs['cls'] = cls.json_decoder
        return json.loads(s, **kwargs)
955262
def get_dict_from_response(response):
    """"""
    result = {}
    if getattr(response, '_resp') and response._resp.code > 400:
        return result

    for i in response.data:
        # strip the schema from the key
        k = i['Type'].replace(REMOTE_APP_RESOURCE_SCHEMA, '')
        result.setdefault(k, list())
        result[k].append(i['Value'])
    return result
930489
def get_json(response):
    """"""

    json_field_or_function = getattr(response, 'json', None)
    if callable(json_field_or_function):
        return response.json()
    else:
        return jsonutils.loads(response.content)
81766
def from_json_str(cls, json_str):
    
    return cls.from_json(json.loads(json_str, cls=JsonDecoder))
587487
def from_response(cls, response: 'ClientResponse') -> Any:
        
        obj = cls.response_wrapper_cls(response, cls(response.headers,
                                                     response.content))
        return obj