Load json data from url and return result.
968526
def __get_url(url):
    """"""
    log.info("Retrieving  weather data (%s)...", url)
    result = {SUCCESS: False, MESSAGE: None}
    try:
        r = requests.get(url)
        result[STATUS_CODE] = r.status_code
        result[HEADERS] = r.headers
        result[CONTENT] = r.text
        if (200 == r.status_code):
            result[SUCCESS] = True
        else:
            result[MESSAGE] = "Got http statuscode: %d." % (r.status_code)
        return result
    except requests.RequestException as ose:
        result[MESSAGE] = 'Error getting url data. %s' % ose
        log.error(result[MESSAGE])

    return result
972584
def load(cls, fp, **kwargs):
    """"""
    json_obj = json.load(fp, **kwargs)
    return parse(cls, json_obj)
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 []
1188430
def get_content_json(request):
    """"""
    result = _get_content_json()

    resp = request.response
    resp.status = "200 OK"
    resp.content_type = 'application/json'
    resp.body = json.dumps(result)
    return result, resp
1059157
def load(self, filename):
        """"""
        LOGGER.info("Loading result from '%s'.", filename)
        if filename.endswith(".gz"):
            with gzip.open(filename, "rb") as file_handle:
                result = MemoteResult(
                    json.loads(file_handle.read().decode("utf-8"))
                )
        else:
            with open(filename, "r", encoding="utf-8") as file_handle:
                result = MemoteResult(json.load(file_handle))
        # TODO (Moritz Beber): Validate the read-in JSON maybe? Trade-off
        #  between extra time taken and correctness. Maybe we re-visit this
        #  issue when there was a new JSON format version needed.
        return result
1338887
function getJSON (url) {
  return new Promise((resolve, reject) => {
    var xhr = new XMLHttpRequest();
    xhr.open('get', url, true);
    xhr.onreadystatechange = function() {
      var status;
      var data;
      if (xhr.readyState === 4) { // `DONE`
        status = xhr.status;
        if (status === 200) {
          data = JSON.parse(xhr.responseText);
          resolve(data);
        } else {
          reject(status);
        }
      }
    };
    xhr.send();
  });
}
197803
def _fetch_json(self):
        """"""
        print("Fetching from url: " + self.graph_url)
        resp = urlopen(self.graph_url).read()
        return json.loads(resp.decode('utf-8'))
1240854
def json(content, request=None, response=None, ensure_ascii=False, **kwargs):
    """"""
    if hasattr(content, 'read'):
        return content

    if isinstance(content, tuple) and getattr(content, '_fields', None):
        content = {field: getattr(content, field) for field in content._fields}
    return json_converter.dumps(content, default=_json_converter, ensure_ascii=ensure_ascii, **kwargs).encode('utf8')
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
        )
566254
def url_read(url, verbose=True):
    
    """
    if url.find('://') == -1:
        url = 'http://' + url
    if verbose:
        print('Reading data from url=%r' % (url,))
    try:
        file_ = _urllib.request.urlopen(url)
        #file_ = _urllib.urlopen(url)
    except IOError:
        raise
    data = file_.read()
    file_.close()
    return data
766583
def get_result(self):
        """"""
        result = get_json_from_remote_server(self.call)
        if result:
            date, value = max(result.iteritems(), key=itemgetter(1))
            return {'date': date, 'users': value}
        else:
            return {'date': "No Data", 'users': 0}
301912
def json_numpy_loader():
    """"""
    data = request.get_json()
    logger.debug('Received JSON data of length {:,}'.format(len(data)))
    return data
943198
def download_as_json(url):
    
    try:
        return Response('application/json', request(url=url)).read()
    except HTTPError as err:
        raise ResponseException('application/json', err)
1176733
def json(body, charset='utf-8', **kwargs):
    """"""
    return json_converter.loads(text(body, charset=charset))
814081
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any:
        """"""
        body = await self.text()
        return loads(body)
1338326
def json_response(data, status=200):
    """"""
    from django.http import JsonResponse
    return JsonResponse(data=data, status=status, safe=isinstance(data, dict))
91152
async def get_json(self, url, timeout=30, astext=False, exceptions=False):
        """"""
        try:
            with async_timeout.timeout(timeout):
                res = await self._aio_session.get(url)
                if res.status != 200:
                    _LOGGER.error("QSUSB returned %s [%s]", res.status, url)
                    return None
                res_text = await res.text()
        except (aiohttp.client_exceptions.ClientError,
                asyncio.TimeoutError) as exc:
            if exceptions:
                raise exc
            return None

        if astext:
            return res_text

        try:
            return json.loads(res_text)
        except json.decoder.JSONDecodeError:
            if res_text.strip(" ") == "":
                return None
            _LOGGER.error("Could not decode %s [%s]", res_text, url)