All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON,
            and check for errors. If all goes well, return the parsed JSON.
500832
def _query(self, url, **kwargs):
        
        parameters = YelpAPI._get_clean_parameters(kwargs)
        response = self._yelp_session.get(
            url,
            headers=self._headers,
            params=parameters,
            timeout=self._timeout_s,
        )
        response_json = response.json()  # shouldn't happen, but this will raise a ValueError if the response isn't JSON

        # Yelp can return one of many different API errors, so check for one of them.
        # The Yelp Fusion API does not yet have a complete list of errors, but this is on the TODO list; see
        # https://github.com/Yelp/yelp-fusion/issues/95 for more info.
        if 'error' in response_json:
            raise YelpAPI.YelpAPIError('{}: {}'.format(response_json['error']['code'],
                                                       response_json['error']['description']))

        # we got a good response, so return
        return response_json
503143
function(url, decode) {

      // If we're passed an object, convert it to a string
      if (typeof url === 'object') url = url.toString();

      // Default decode to true
      if (typeof decode === 'undefined') decode = true;

      // Extract query string from url
      var query_string = this.search(url);

      // Replace the starting ?, if it is there
      query_string = query_string.replace(/^\?/, '');

      var parts;

      // If query string is blank, parts should be blank
      if (query_string === '') {
        parts = [];
      } else {
        // Split the query string into key value parts
        parts = query_string.split('&');
      }

      // Iniate the return value
      var query = {};

      // Loop through each other the parts, splitting it into keys and values
      for (var i = 0, l = parts.length; i < l; i++) {
        var part = parts[i];
        var key;
        var val = '';

        if (part.match('=')) {
          // If it is in the format key=val

          // Split into the key and value by the = symbol
          var part_parts = part.split('=');

          // Assign key and value
          key = part_parts[0];
          val = part_parts[1];
        } else {
          // If there is no value, just set the key to the full part
          key = part;
        }

        // If we actually have a value, URI decode it
        if (val !== '' && decode) {
          val = decodeURIComponent(val);
        }

        // Assign to the return value
        query[key] = val;
      }

      return query;
    }
825433
def _http_call(self, url, method, data=None, **kwargs):
        
        response = self._http_response(url, method, data=data, **kwargs)
        if not response.content:
            return {}

        return response.json()
33549
async def fetchResults(self, url, post_data=None):
    
    if post_data is not None:
      self.logger.debug("Querying URL '%s' %s..." % (url, dict(post_data)))
    else:
      self.logger.debug("Querying URL '%s'..." % (url))
    headers = {}
    self.updateHttpHeaders(headers)
    return await self.http.query(url,
                                 post_data=post_data,
                                 headers=headers,
                                 cache=__class__.api_cache)
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
461079
async def get_all(self, url, params=None):
        
        if not params:
            params = {}
        items = []
        next_page_token = None

        while True:
            if next_page_token:
                params['pageToken'] = next_page_token
            response = await self.get_json(url, params=params)

            items.append(response)
            next_page_token = response.get('nextPageToken')
            if not next_page_token:
                break
        return items
237965
def get_json_online(self, url):
        
        if not requests:
            return False
        try:
            req = requests.get(url, timeout=.2)
            if not req.ok:
                return []
            return req
        except (requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError,
                requests.exceptions.ReadTimeout):
            return []
830615
function (url) {
        var self = this;
        this.searching = true;
        this.loadingError = false;
        return $http.get(url)
          .success(function (res) {
            self.searching = false;
            return res.data;
          })
          .error(function () {
            self.searching = false;
            self.loadingError = true;
            return false;
          });
      }
1374568
function(method, url, headers, data, callback) {

		var r = new XMLHttpRequest();
		var error = this.error;

		// Binary?
		var binary = false;
		if (method === 'blob') {
			binary = method;
			method = 'GET';
		}

		method = method.toUpperCase();

		// Xhr.responseType 'json' is not supported in any of the vendors yet.
		r.onload = function(e) {
			var json = r.response;
			try {
				json = JSON.parse(r.responseText);
			}
			catch (_e) {
				if (r.status === 401) {
					json = error('access_denied', r.statusText);
				}
			}

			var headers = headersToJSON(r.getAllResponseHeaders());
			headers.statusCode = r.status;

			callback(json || (method === 'GET' ? error('empty_response', 'Could not get resource') : {}), headers);
		};

		r.onerror = function(e) {
			var json = r.responseText;
			try {
				json = JSON.parse(r.responseText);
			}
			catch (_e) {}

			callback(json || error('access_denied', 'Could not get resource'));
		};

		var x;

		// Should we add the query to the URL?
		if (method === 'GET' || method === 'DELETE') {
			data = null;
		}
		else if (data && typeof (data) !== 'string' && !(data instanceof FormData) && !(data instanceof File) && !(data instanceof Blob)) {
			// Loop through and add formData
			var f = new FormData();
			for (x in data) if (data.hasOwnProperty(x)) {
				if (data[x] instanceof HTMLInputElement) {
					if ('files' in data[x] && data[x].files.length > 0) {
						f.append(x, data[x].files[0]);
					}
				}
				else if (data[x] instanceof Blob) {
					f.append(x, data[x], data.name);
				}
				else {
					f.append(x, data[x]);
				}
			}

			data = f;
		}

		// Open the path, async
		r.open(method, url, true);

		if (binary) {
			if ('responseType' in r) {
				r.responseType = binary;
			}
			else {
				r.overrideMimeType('text/plain; charset=x-user-defined');
			}
		}

		// Set any bespoke headers
		if (headers) {
			for (x in headers) {
				r.setRequestHeader(x, headers[x]);
			}
		}

		r.send(data);

		return r;

		// Headers are returned as a string
		function headersToJSON(s) {
			var r = {};
			var reg = /([a-z\-]+):\s?(.*);?/gi;
			var m;
			while ((m = reg.exec(s))) {
				r[m[1]] = m[2];
			}

			return r;
		}
	}
447270
function json(url, callback) {
    return request(url, function(req) {
      if (req.responseText) callback(JSON.parse(req.responseText));
    }, "application/json");
  }
256443
def get(url, parameters = {}, skip_status_check = false)
      response = connection.get("#{api_endpoint}#{url}", parameters)
      on_complete(response) unless skip_status_check
      response
    end
951745
def request(self, url, method="get", format="json", data=None,
                expected_status=None, headers=None, use_xpost=True, **options):
        
        if expected_status is None:
            if method == "get":
                expected_status = 200
            elif method == "post":
                expected_status = 201
            else:
                raise ValueError("No expected status supplied and method unknown.")

        if not url.startswith("http"):
            url = "{self.host}/api/v4/{url}".format(**locals())
        if format is not None:
            options = dict({'format': format}, **options)
        options = {field: value for field, value in options.items() if value is not None}
        headers = dict(headers or {}, Authorization="Token {}".format(self.token))
        #headers['Accept-encoding'] = 'gzip'

        if method == "get" and use_xpost:
            # If method is purely GET, we can use X-HTTP-METHOD-OVERRIDE to send our
            # query via POST. This allows for a large number of parameters to be supplied
            assert(data is None)

            headers.update({"X-HTTP-METHOD-OVERRIDE": method})
            data = options
            options = None
            method = "post"

        r = requests.request(method, url, data=data, params=options, headers=headers)

        log.debug(
            "HTTP {method} {url} (options={options!r}, data={data!r},"
            "headers={headers}) -> {r.status_code}".format(**locals())
        )
        return check(r, expected_status=expected_status)
183257
def _request(self, method, url, query_or_data=None, **kwargs):
        

        if query_or_data is None:
            query_or_data = {}

        request_method = getattr(self, '_http_{0}'.format(method))
        response = retry_request(self)(request_method)(url, query_or_data, **kwargs)

        if self.raw_mode:
            return response

        if response.status_code >= 300:
            error = get_error(response)
            if self.raise_errors:
                raise error
            return error

        # Return response object on NoContent
        if response.status_code == 204 or not response.text:
            return response

        return ResourceBuilder(
            self,
            self.default_locale,
            response.json()
        ).build()
1076375
def _urlopen_as_json(self, url, headers=None):
        """"""
        req = Request(url, headers=headers)
        return json.loads(urlopen(req).read())
504000
def json_parse(self, response):
        
        try:
            data = response.json()
        except ValueError:
            data = {'meta': { 'status': 500, 'msg': 'Server Error'}, 'response': {"error": "Malformed JSON or HTML was returned."}}

        # We only really care about the response if we succeed
        # and the error if we fail
        if 200 <= data['meta']['status'] <= 399:
            return data['response']
        else:
            return data
11617
def parse_json(self, page):
        ''''''
        if not isinstance(page, basestring):
            page = util.decode_page(page)
            
        self.doc = json.loads(page)
        results = self.doc.get(self.result_name, [])
    
        if not results:
            self.check_status(self.doc.get('status'))
            return None
            
            
        return results
340715
def get(self, url):
        
        r = requests.get(self._format_url(url), headers=self.headers, timeout=TIMEOUT)
        self._check_response(r, 200)

        return r.json()