:param response_json: the json obj returned from query
        :return:
433596
def _update_state_from_response(self, response_json):
        
        if response_json.get('data') is not None:
            cloud_clock = response_json.get('data')
        else:
            cloud_clock = response_json
        self.parent.json_state = cloud_clock

        cloud_clock_last_reading = cloud_clock.get('last_reading')
        dials = cloud_clock.get('dials')
        for dial in dials:
            if dial.get('object_id') == self.object_id():
                dial['connection'] = cloud_clock_last_reading.get('connection')
                self.json_state = dial
                return True
        return False
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')
767963
def response_json(self, status, response, content_type='application/json', encoding='utf-8', headers=None, jsonp=None):
        

        encoder = JSONEncoder(
            check_circular=self.app.validate_output,
            allow_nan=False,
            sort_keys=True,
            indent=2 if self.app.pretty_output else None,
            separators=(',', ': ') if self.app.pretty_output else (',', ':')
        )
        content = encoder.encode(response)
        if jsonp:
            content_list = [jsonp.encode(encoding), b'(', content.encode(encoding), b');']
        else:
            content_list = [content.encode(encoding)]
        return self.response(status, content_type, content_list, headers=headers)
730037
def deserialize(self, response_json):
        
        response_objects = dict()
        if all((t in response_json for t in ('ticket', 'audit'))):
            response_objects["ticket_audit"] = self.object_mapping.object_from_json(
                "ticket_audit",
                response_json
            )

        # Locate and store the single objects.
        for zenpy_object_name in self.object_mapping.class_mapping:
            if zenpy_object_name in response_json:
                zenpy_object = self.object_mapping.object_from_json(
                    zenpy_object_name,
                    response_json[zenpy_object_name]
                )
                response_objects[zenpy_object_name] = zenpy_object

        # Locate and store the collections of objects.
        for key, value in response_json.items():
            if isinstance(value, list):
                zenpy_object_name = as_singular(key)
                if zenpy_object_name in self.object_mapping.class_mapping:
                    response_objects[key] = []
                    for object_json in response_json[key]:
                        zenpy_object = self.object_mapping.object_from_json(
                            zenpy_object_name,
                            object_json
                        )
                        response_objects[key].append(zenpy_object)
        return response_objects
1338326
def json_response(data, status=200):
    """"""
    from django.http import JsonResponse
    return JsonResponse(data=data, status=status, safe=isinstance(data, dict))
747188
def _json_to_supported(response_body):
    
    data = json.loads(response_body)
    supported = []
    for supported_data in data.get("supportedList", []):
        supported.append(Supported().from_json(
            supported_data))

    return supported
477921
def _rest_request_to_json(self, address, object_path, service_name, requests_config, tags, *args, **kwargs):
        
        response = self._rest_request(address, object_path, service_name, requests_config, tags, *args, **kwargs)

        try:
            response_json = response.json()

        except JSONDecodeError as e:
            self.service_check(
                service_name,
                AgentCheck.CRITICAL,
                tags=['url:%s' % self._get_url_base(address)] + tags,
                message='JSON Parse failed: {0}'.format(e),
            )
            raise

        return response_json
1161698
def _collection_json_response(cls, resources, start, stop, depth=0):
    

    top_level_json_name = None
    if cls.__top_level_json_name__ is not None:
        top_level_json_name = cls.__top_level_json_name__
    else:
        top_level_json_name = 'resources'

    result_list = []
    for resource in resources:
        result_list.append(resource.as_dict(depth))

    payload = {}
    if start is not None:
        payload[top_level_json_name] = result_list[start:stop]
    else:
        payload[top_level_json_name] = result_list

    return jsonify(payload)
701
def make_json_response(rv):
    
    # Tuple of (response, status, headers)
    rv, status, headers = normalize_response_value(rv)

    # JsonResponse
    if isinstance(rv, JsonResponse):
        return rv

    # Data
    return JsonResponse(rv, status, headers)
975154
def render_to_response(self, context, indent=None):
        ""
        return self.get_json_response(self.convert_context_to_json(context, indent=indent))
109971
def _list_response(self, response):
        
        if type(response) is list:
            return response
        if type(response) is dict:
            return [response]
956297
def json(func):
    
    if inspect.isclass(func):
        apply_function_to_members(func, json)
        return func
    else:
        @functools.wraps(func)
        def decorated_view(*args, **kwargs):
            data = func(*args, **kwargs)
            return _build_response(data, jsonify)
        return decorated_view
453251
def render_json_response(self, context_dict, status=200):
        
        json_context = json.dumps(
            context_dict,
            cls=DjangoJSONEncoder,
            **self.get_json_dumps_kwargs()
        ).encode(u'utf-8')
        return HttpResponse(
            json_context,
            content_type=self.get_content_type(),
            status=status
        )
811648
def _get_json_response(self, resp):
        '''  '''
        if resp is not None and resp.text is not None:
            try:
                text = resp.text.strip('\n')
                if len(text) > 0:
                    return json.loads(text)
            except ValueError as e:
                if self.debug:
                    print("Could not decode JSON response: \"%s\"" % resp.text)
                raise e
475758
def jsonify(obj, status=200, headers=None):
    
    data = JSONEncoder().encode(obj)
    if 'callback' in request.args:
        cb = request.args.get('callback')
        data = '%s && %s(%s)' % (cb, cb, data)
    return Response(data, headers=headers, status=status,
                    mimetype='application/json')
1055537
def collection_response(cls, resources, start=None, stop=None):
    
    if _get_acceptable_response_type() == JSON:
        return _collection_json_response(cls, resources, start, stop)
    else:
        return _collection_html_response(resources, start, stop)
135685
def fetch_json(self, method, url, data=None, expected_status_code=None):
        
        return self.fetch(method, url, data, expected_status_code).json()