Returns a full response using the result of a call to simple_data, by default an instance of Collection, otherwise, an array or JSON
323648
protected function response($type = "json"){
			$content = $this->simple_data($this->endpoint, $this->options->toArray());
			$response = new Response;
			$response->setPublic();			
			if($this->options->get('allow_origin'))
				$response->header('Access-Control-Allow-Origin', $this->options->get('allow_origin'));
			$response->setContent($content)->send();
		}
919153
def post_json(path, object_to_post, response_type = nil)
      response_type = SimpleSolrClient::Response::GenericResponse if response_type.nil?
      response_type.new(_post_json(path, object_to_post))
    end
53290
def get_json_response(self):
        
        self.json_response = self.get_response().json()
        if self.json_response is not None:
            error_code = self.json_response.get("errcode", None)
            self.call_status = True if error_code == 0 else False
        return self.json_response
791068
def resource_response(resource, depth=0):
    
    if _get_acceptable_response_type() == JSON:
        depth = 0
        if 'expand' in request.args:
            depth = 1
        return _single_resource_json_response(resource, depth)
    else:
        return _single_resource_html_response(resource)
1193671
function formatResponse (res) {
    // iterate over rows in response
    _.each(res, row => {
        // iterate over key/value pairs in row object
        _.each(row, (val, key) => {
            // convert nulls to undefined
            if (val === null) {
                row[key] = undefined
            }
        })
    })
}
1014695
def _request_process_json_standard(self, response_data):
        
        data = response_data.get('data', {}).get(self.request_entity, [])
        status = response_data.get('status', 'Failure')
        return data, status
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)
925059
public function getResponse()
    {
        $this->execute();
        
        switch ($this->def['dataType']) {
            case 'array':
                $result = static::toArray();
                break;
            case 'object':
            case 'json':
                $result = static::toJson();
                break;
            default:
                $result = $this->getErrorString() ? : $this->responseText;
        }
        
        return $result;
    }
708665
private function getResponseArray($data, $responseExpectedFormat = 'json')
    {
        $result = $hierarchy = [];
        try {
            switch ($responseExpectedFormat) {
                case 'headers':
                    foreach ($data as $key => $array) {
                        $result[$key] = implode('; ', $array);
                    }
                    break;

                case 'xml':
                case 'html':
                    if (
                        false !== strpos($data, '<')
                        && false !== strpos($data, '>')
                    ) {
                        $doc          = new DOMDocument();
                        $doc->recover = true;
                        $data         = trim($data);
                        // Ensure UTF-8 encoding is handled correctly.
                        if (1 !== preg_match('/^<\??xml .*encoding=["|\']?UTF-8["|\']?.*>/iU', $data, $matches)) {
                            // Possibly missing UTF-8 specification.
                            $opening      = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
                            $replaceCount = 0;
                            $data         = preg_replace(
                                '/^<\??xml(.*)\?*>/iU',
                                $opening,
                                $data,
                                1,
                                $replaceCount
                            );
                            if (!$replaceCount) {
                                // Missing opening XML block entirely.
                                $data = $opening.$data;
                            }
                        }
                        if ('html' == $responseExpectedFormat) {
                            @$doc->loadHTML($data);
                        } else {
                            @$doc->loadXML($data);
                        }
                        $hierarchy = $this->domDocumentArray($doc);
                    }
                    break;

                case 'json':
                    $jsonHelper = new JSONHelper();
                    $hierarchy  = $jsonHelper->decodeArray($data, 'API Response', true);
                    break;

                case 'text':
                    // Handle the most common patterns of a multi-line delimited expression.
                    foreach (explode("\n", $data) as $line) {
                        if (!empty($line)) {
                            foreach ([':', '=', ';'] as $delimiter) {
                                $elements = explode($delimiter, $line);
                                if (2 == count($elements)) {
                                    // Strip outer whitespace.
                                    foreach ($elements as &$element) {
                                        $element = trim($element);
                                    }
                                    unset($element);
                                    // Strip enclosures.
                                    foreach ($elements as &$element) {
                                        foreach (['"', "'"] as $enclosure) {
                                            if (
                                                0 === strpos($element, $enclosure)
                                                && strrpos($element, $enclosure) === strlen($element) - 1
                                            ) {
                                                $element = trim($element, $enclosure);
                                                continue;
                                            }
                                        }
                                    }
                                    unset($element);
                                    list($key, $value) = $elements;
                                    $result[$key]      = $value;
                                    break;
                                }
                            }
                        }
                    }
                    // Fall back to a raw string (no key-value pairs at all)
                    if (!$result) {
                        foreach (explode("\n", $data) as $l => $line) {
                            $result['line '.($l + 1)] = $line;
                        }
                    }
                    break;

                case 'yaml':
                    $yaml = Yaml::parse($data, true);
                    if (is_array($yaml) || is_object($yaml)) {
                        $hierarchy = $yaml;
                    }
                    break;
            }
        } catch (\Exception $e) {
            // Sub-parsing may fail, but we only care about acceptable values when validating.
            // Logging will capture the full response for debugging.
        }

        // Flatten hierarchical data, if needed.
        if ($hierarchy) {
            if (!is_array($hierarchy) && !is_object($hierarchy)) {
                $hierarchy = [$hierarchy];
            }
            $result = $this->flattenStructure($hierarchy);
        }

        // Stringify all values.
        foreach ($result as $key => &$value) {
            if (true === $value) {
                $value = 'true';
            } elseif (false === $value) {
                $value = 'false';
            }
            $value = (string) $value;
        }

        return $result;
    }
161230
function(data) {
    var h, headerArray, headers, i, l, len, o;
    headers = {};
    headerArray = data.getAllResponseHeaders().split('\r');
    for (l = 0, len = headerArray.length; l < len; l++) {
      i = headerArray[l];
      h = i.match(/^([^:]*?):(.*)$/);
      if (!h) {
        h = [];
      }
      h.shift();
      if (h[0] !== void 0 && h[1] !== void 0) {
        headers[h[0].trim()] = h[1].trim();
      }
    }
    o = {};
    o.content = {};
    o.content.data = data.responseText;
    o.headers = headers;
    o.request = {};
    o.request.url = this.invocationUrl;
    o.status = data.status;
    return o;
  }
546790
def all
      response = request(:get_all)
      handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }
      get_data_for_handles(handles)

      self
    end
943493
def _build_response(data, renderer=None):
    
    if isinstance(data, Response) or isinstance(data, BaseResponse):
        return data
    if not renderer:
        raise AttributeError(" Renderer is required")
    if isinstance(data, dict) or data is None:
        data = {} if data is None else data
        for _ in __view_parsers:
            data = _(data)
        return renderer(data), 200
    elif isinstance(data, tuple):
        data, status, headers = _normalize_response_tuple(data)
        for _ in __view_parsers:
            data = _(data)
        return renderer(data or {}), status, headers
    return data
1112214
def handle_response(self, content, target=None, single_result=True, raw=False):
        
        response = content['response']

        self.check_errors(response)

        data = response.get('data')

        if is_empty(data):
            return data
        elif is_paginated(data):
            if 'count' in data and not data['count']:
                # Response is paginated, but is empty
                return data['data']
            data = data['data']

        if raw:
            return data
        return self.init_all_objects(data, target=target, single_result=single_result)
590201
def wrap_json_response(func=None, *, encoder=json.JSONEncoder):
    

    if func is None:
        return functools.partial(wrap_json_response, encoder=encoder)

    @functools.wraps(func)
    def wrapper(request, *args, **kwargs):
        response = func(request, *args, **kwargs)

        if "Content-Type" in response.headers and response.headers['Content-Type'] is not None:
            ctype, pdict = parse_header(response.headers.get('Content-Type', ''))
            if ctype == "application/json" and (isinstance(response.body, dict) or isinstance(response.body, list)):
                response.body = json.dumps(response.body, cls=encoder)
        return response

    return wrapper
713967
def _wrap_response(request, data=None, metadata=None, status=200):
        
        envelope = metadata or {}

        if data is not None:
            envelope['data'] = data

        return web.Response(
            status=status,
            content_type='application/json',
            text=json.dumps(
                envelope,
                indent=2,
                separators=(',', ': '),
                sort_keys=True))
856656
function GetResponse(model, paths, isJSONGraph,
                                       isProgressive, forceCollect) {
    this.model = model;
    this.currentRemainingPaths = paths;
    this.isJSONGraph = isJSONGraph || false;
    this.isProgressive = isProgressive || false;
    this.forceCollect = forceCollect || false;
}
758811
def results(self, request):
        ""
        results = {}
        form = self.form(request.GET)
        if form.is_valid():
            options = form.cleaned_data
            term = options.get('term', '')
            raw_data = self.get_query(request, term)
            results = self.format_results(raw_data, options)
        return self.response(results)