A shorthand of _query() that treats the input as JSON.
421686
async def _query_json(
        self, path, method="GET", *, params=None, data=None, headers=None, timeout=None
    ):
        
        if headers is None:
            headers = {}
        headers["content-type"] = "application/json"
        if not isinstance(data, (str, bytes)):
            data = json.dumps(data)
        response = await self._query(
            path, method, params=params, data=data, headers=headers, timeout=timeout
        )
        data = await parse_result(response)
        return data
417679
def as_json(only: nil, except: nil, context: {})
      execute(Introspection::INTROSPECTION_QUERY, only: only, except: except, context: context).to_h
    end
869623
def __yahoo_request(query):
    
    query = quote(query)
    url = 'https://query.yahooapis.com/v1/public/yql?q=' + query + \
        '&format=json&env=store://datatables.org/alltableswithkeys'

    response = urlopen(url).read()

    return json.loads(response.decode('utf-8'))['query']['results']
1136364
def query(options, collection_name, num_to_skip,
          num_to_return, query, field_selector, opts, check_keys=False):
    
    data = struct.pack("<I", options)
    data += bson._make_c_string(collection_name)
    data += struct.pack("<i", num_to_skip)
    data += struct.pack("<i", num_to_return)
    encoded = bson.BSON.encode(query, check_keys, opts)
    data += encoded
    max_bson_size = len(encoded)
    if field_selector is not None:
        encoded = bson.BSON.encode(field_selector, False, opts)
        data += encoded
        max_bson_size = max(len(encoded), max_bson_size)
    (request_id, query_message) = __pack_message(2004, data)
    return (request_id, query_message, max_bson_size)
769334
def query(string):
	
	url = "https://api.duckduckgo.com/?q="
	formating = "&format=json"
	query_string = url+'+'.join(string)+formating
	try:
		result = json.loads(requests.get(query_string).text)
	except:
		print "I'm sorry! Something went wrong. Maybe we could try again later."
		return
	parse_result(result)
883089
def _canonicalize_query(self, query):

        

        def transform_query(q):

            for encoder in self.query_encoders:
                q = encoder.encode(q,[])

            if isinstance(q, dict):
                nq = {}
                for key,value in q.items():
                    new_key = key
                    if isinstance(value,dict) and len(value) == 1 and list(value.keys())[0].startswith('$'):
                        if list(value.keys())[0] in ('$all','$in'):
                            if list(value.values())[0] and isinstance(list(value.values())[0][0],Document):
                                if self._use_pk_based_refs:
                                    new_key+='.pk'
                                else:
                                    new_key+='.__ref__'
                    elif isinstance(value,Document):
                        if self._use_pk_based_refs:
                            new_key+='.pk'
                        else:
                            new_key+='.__ref__'
                    nq[new_key] = transform_query(value)
                return nq
            elif isinstance(q, (list,QuerySet,tuple)):
                return [transform_query(x) for x in q]
            elif isinstance(q,Document):
                collection = self.get_collection_for_obj(q)
                if self._use_pk_based_refs:
                    return q.pk
                else:
                    return "%s:%s" % (collection,q.pk)
            else:
                return q

        return transform_query(query)
418756
def _prepare_request_json(self, kwargs):
        """"""

        # Check for python keywords in dict
        kwargs = self._check_for_python_keywords(kwargs)

        # Check for the key 'check' in kwargs
        if 'check' in kwargs:
            od = OrderedDict()
            od['check'] = kwargs['check']
            kwargs.pop('check')
            od.update(kwargs)
            return od
        return kwargs
44992
def parse_query_filter():
    """"""
    query_string = request.args.get("queryFilter")
    if query_string is None:
        return {"type": "and", "filters": []}
    query = json.loads(query_string)
    assert type(query) == dict
    assert type(query.get("type")) == str
    return query
645587
def _get_query(self, query, params):
        
        if "apikey" not in params:
            params["apikey"] = self.api_key

        response = requests.get(query, params=params)
        return response.json()
716022
def maybe_print_as_json(opts, data, page_info=None):
    """"""
    if opts.output not in ("json", "pretty_json"):
        return False

    root = {"data": data}

    if page_info is not None and page_info.is_valid:
        meta = root["meta"] = {}
        meta["pagination"] = page_info.as_dict(num_results=len(data))

    if opts.output == "pretty_json":
        dump = json.dumps(root, indent=4, sort_keys=True)
    else:
        dump = json.dumps(root, sort_keys=True)

    click.echo(dump)
    return True
435943
def from_json(cls, json):
    """"""
    obj = cls(key_range.KeyRange.from_json(json["key_range"]),
              model.QuerySpec.from_json(json["query_spec"]))
    cursor = json["cursor"]
    # lint bug. Class method can access protected fields.
    # pylint: disable=protected-access
    if cursor and json["cursor_object"]:
      obj._cursor = datastore_query.Cursor.from_websafe_string(cursor)
    else:
      obj._cursor = cursor
    return obj
777464
def get_query_param(request, key):
    """"""
    value = request.query_params.get(key) or request.data.get(key)
    if value is None:
        raise KeyError()
    return value
84233
def _get_json_obj(self, endpoint, query, is_post=False):
        
        response = self._get_response(endpoint, query, is_post=is_post)
        content = response.text
        try:
            return loads(content)
        except ValueError:
            raise Exception('Could not decode content to JSON:\n%s'
                            % self.__class__.__name__, content)
65600
def query_params(self, params, key, def_value, short_hand=None):
    
    if key not in params and short_hand:
        # value is associated with shorthand, move to key
        params[key] = params.get(short_hand, def_value)
        del params[short_hand]
    elif key not in params and not short_hand:
        params[key] = def_value
    elif key in params:
        # key is there, also possibly shorthand
        # assume def value at this point is not needed
        if short_hand in params:
            del params[short_hand]
    return params
705887
function jsonp() {
    function _jsonp(req, res, next) {
        var q = req.getQuery();

        // If the query plugin wasn't used, we need to hack it in now
        if (typeof (q) === 'string') {
            req.query = qs.parse(q);
        }

        if (req.query.callback || req.query.jsonp) {
            res.setHeader('Content-Type', 'application/javascript');
        }

        next();
    }

    return (_jsonp);
}
450666
function reqToJSON () {
  const {ip, method, url, headers} = this
  const userAgent = headers ? headers['user-agent'] : void (0)
  return {ip, method, url, userAgent}
}
1122357
def query(self):
        
        query_context = QueryContext(**json.loads(request.form.get('query_context')))
        security_manager.assert_datasource_permission(query_context.datasource)
        payload_json = query_context.get_payload()
        return json.dumps(
            payload_json,
            default=utils.json_int_dttm_ser,
            ignore_nan=True,
        )