Pull a json value from the request.
320476
async def parse_json(self, req: Request, name: str, field: Field) -> typing.Any:
        """"""
        json_data = self._cache.get("json")
        if json_data is None:
            if not (req.body_exists and is_json_request(req)):
                return core.missing
            try:
                json_data = await req.json(loads=json.loads)
            except json.JSONDecodeError as e:
                if e.doc == "":
                    return core.missing
                else:
                    return self.handle_invalid_json_error(e, req)
            self._cache["json"] = json_data
        return core.get_value(json_data, name, field, allow_many_nested=True)
434744
def json(self, **kwargs):
        
        try:
            return super(ScraperResponse, self).json(**kwargs)
        except ValueError as ve:
            raise ParseException(ve)
145515
def get_data_from_request():
    """"""
    return {
        'request': {
            'url': '%s://%s%s' % (web.ctx['protocol'], web.ctx['host'], web.ctx['path']),
            'query_string': web.ctx.query,
            'method': web.ctx.method,
            'data': web.data(),
            'headers': dict(get_headers(web.ctx.environ)),
            'env': dict(get_environ(web.ctx.environ)),
        }
    }
1275461
def load_from_json(data):
        
        if isinstance(data, str):
            data = json.loads(data)
        return Item(data['title'], data['uri'])
740648
def _get_json(self, url):
        ""
        content = self._get_content('jsonds/' + url)
        try:
            json_content = json.loads(content.decode())
        except AttributeError:
            json_content = json.loads(content)
        if json_content['Comment']:
            log.warning(json_content['Comment'])
        if json_content['Result'] != 'OK':
            raise ValueError('Error while retrieving the parameter list.')
        return json_content['Data']
430058
def parse_request(request, input_schema, raw):
    """"""

    request.json = {}
    if not raw:
        body = yield from request.read()
        if body:
            try:
                request.json = json.loads(body.decode('utf-8'))
            except ValueError as e:
                request.json = {"malformed_json": body.decode('utf-8')}
                raise aiohttp.web.HTTPBadRequest(text="Invalid JSON {}".format(e))

    # Parse the query string
    if len(request.query_string) > 0:
        for (k, v) in urllib.parse.parse_qs(request.query_string).items():
            request.json[k] = v[0]

    if input_schema:
        try:
            jsonschema.validate(request.json, input_schema)
        except jsonschema.ValidationError as e:
            log.error("Invalid input query. JSON schema error: {}".format(e.message))
            raise aiohttp.web.HTTPBadRequest(text="Invalid JSON: {} in schema: {}".format(
                e.message,
                json.dumps(e.schema)))

    return request
1083185
def get_json(session, url, params: dict = None):
    
    res = session.get(url, params=params)
    if res.status_code >= 400:
        raise parse_error(res)
    return res.json()
490914
def get(self, endpoint):
        ''''''
        json_body = urlopen(self.url(endpoint)).read().decode('utf-8')
        return json.loads(json_body)
217837
def parse_json(self, req, name, field):
        """"""
        if not (req.body and is_json_request(req)):
            return core.missing
        json_data = req.json
        if json_data is None:
            return core.missing
        return core.get_value(json_data, name, field, allow_many_nested=True)
773264
def from_json(cls, json_str):
        """"""
        d = json.loads(json_str)
        return cls.from_dict(d)
924243
def for_json(self):
        """"""

        if self.multiselect:
            return super(MultiSelectField, self).for_json()

        value = self.get_python()
        if hasattr(value, 'for_json'):
            return value.for_json()

        return value
263839
async def get_json(self, encoding='utf-8'):
        """"""
        return (await self.get(encoding=encoding, decoder=json.loads))
632246
def json_requested():
    """"""
    best = request.accept_mimetypes.best_match(
        ['application/json', 'text/html'])
    return (best == 'application/json' and
            request.accept_mimetypes[best] >
            request.accept_mimetypes['text/html'])
814081
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any:
        """"""
        body = await self.text()
        return loads(body)
921631
def _get_json(self, url):
        
        self.log.info(u"/GET " + url)
        r = requests.get(url)
        if hasattr(r, 'from_cache'):
            if r.from_cache:
                self.log.info("(from cache)")
        if r.status_code != 200:
            throw_request_err(r)

        return r.json()
62733
def get_json(request, token):
    """"""
    result = []
    searchtext = request.GET['q']
    if len(searchtext) >= 3:
        pickled = _simple_autocomplete_queryset_cache.get(token, None)
        if pickled is not None:
            app_label, model_name, query = pickle.loads(pickled)
            model = apps.get_model(app_label, model_name)
            queryset = QuerySet(model=model, query=query)
            fieldname = get_search_fieldname(model)
            di = {'%s__istartswith' % fieldname: searchtext}
            app_label_model = '%s.%s' % (app_label, model_name)
            max_items = get_setting(app_label_model, 'max_items', 10)
            items = queryset.filter(**di).order_by(fieldname)[:max_items]

            # Check for duplicate strings
            counts = {}
            for item in items:
                if hasattr(item, "__unicode__"):
                    key = item.__unicode__()
                else:
                    key = str(item)
                #key = unicode(item)
                counts.setdefault(key, 0)
                counts[key] += 1

            # Assemble result set
            for item in items:
                #key = value = unicode(item)
                if hasattr(item, "__unicode__"):
                    key = value = item.__unicode__()
                else:
                    key = value = str(item)
                value = getattr(item, fieldname)
                if counts[key] > 1:
                    func = get_setting(
                        app_label_model,
                        'duplicate_format_function',
                        lambda obj, model, content_type: content_type.name
                    )
                    content_type = ContentType.objects.get_for_model(model)
                    value = '%s (%s)' % (value, func(item, model, content_type))
                result.append((item.id, value))

        else:
            result = 'CACHE_MISS'

    return HttpResponse(json.dumps(result))
767746
def json(self):
        
        try:
            return self._json
        except AttributeError:
            try:
                self._json = json.loads(self.text)
                return self._json
            except:  # noqa e722
                raise RequestInvalidJSON("Invalid JSON received")