/*
Make sure it's a JSON request
763363
public Map<String, String> getRequestHeaders() {
        Map<String, String> hdrs = new HashMap<>();
        hdrs.put("Content-Type", "application/json");
        hdrs.put("environment", getSlackPrefix());
        return hdrs;
    }
1253745
def is_json(self, headers):
        """"""
        ret = False
        ct = headers.get("content-type", "").lower()
        if ct:
            ret = ct.lower().rfind("json") >= 0
        return ret
775196
def _json_request(self, method, path, data):
        

        response = self._request(method, path, data=data)
        _raise_for_status(response)
        if len(response.data) > 0:
            return _json_from_response(response)
        return response.data
850498
protected function _getJsonRpcRequest() {
        if ($this->getRequest()->getPost('request')) {
            return $this->getRequest()->getPost('request');
        }
        return $request = $this->getRequest()->getRawBody();
    }
1239164
function ( json ) {
    pageNotFoundJson = sqsUtil.copy( json );
    pageNotFoundJson.collection = {};
    pageNotFoundJson.error = true;
}
628432
def requires_application_json(f):
    """"""

    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        from flask import request
        if request.get_json(silent=True) is None:
            er = ErrorResponse(description='Improper Content-Type header. Expecting "application/json"')
            return to_json_response(er), HTTPStatus.BAD_REQUEST
        else:
            return f(*args, **kwargs)

    return wrapped
958911
function requestJson(method, url, successCallback, failureCallback) {
    successCallback = successCallback || console.log;
    failureCallback = failureCallback || console.error || console.warn || console.log;
    var xhr = (typeof XDomainRequest !== 'undefined') ?
      (new XDomainRequest()) :
      (new XMLHttpRequest());
    xhr.onreadystatechange = function (event) {
      if (event.target.readyState === 4) {
        /* parse response as JSON */
        var responseJson;
        try { responseJson = window.JSON.parse(event.target.response); }
        catch (exception) { return failureCallback(event.target.response, exception); }
        /* perform callback according to HTTP status code */
        if (xhr.status > 0 && xhr.status < 400) {
          return successCallback(responseJson);
        } else {
          return failureCallback(responseJson);
        }
      }
    };
    xhr.open(method, url, true);
    xhr.send();
  }
11215
function makeRequest(title, cacheHitExpected, next) {
  var start = Date.now();

  request({
    url: 'http://localhost:1337/',
    encoding: null
  }, function(err, data, body) {
    var time = Date.now() - start;

    var receivedImage = new Buffer(body, 'binary');

    console.log(title);
    console.log('  status:', data.statusCode);
    console.log('  sent image length:', IMAGE.length);
    console.log('  received image length  :', receivedImage.length);
    console.log('  time  :', time);
    
    common.verify(function() {
      common.shouldEquals(IMAGE, receivedImage);
    });

    console.log();

    next();
  });
}
72884
protected function _reformJsonRpcRequest($request) {
        /**
         * Sanity check, if the right properties are not found in the object,
         * pass the original along to Zend_Json_Server and let it fail.
         */
        if (!is_array($request)
            || !array_key_exists('method', $request)
            || !array_key_exists('params', $request)
        ) {
            return $request;
        }
        $meth = $request['method'];
        $meth = explode('.', $meth);
        // send everything thru Garp_Content_Manager_Proxy::pass
        $request['method'] = 'pass';
        $request['params'] = array($meth[0], $meth[1], $request['params']);
        return $request;
    }
1215484
def _request(self, path, method, body=None):
        """"""
        url = '/'.join([_SERVER, path])
        (resp, content) = _HTTP.request(url, method,
                                        headers=self._headers, body=body)

        content_type = resp.get('content-type')
        if content_type and content_type.startswith('application/json'):
            content = json.loads(content.decode('UTF-8'))

        return (resp, content)
57963
function isJson(str) {
        try {
            var obj = JSON.parse(str);
            return this.isObject(obj);
        } catch (e) {/* ignore */}

        return false;
    }
755536
public static boolean isValidJson(String s) {
		try {
			new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(s, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
1076375
def _urlopen_as_json(self, url, headers=None):
        """"""
        req = Request(url, headers=headers)
        return json.loads(urlopen(req).read())
1330794
public function wantsJson()
    {
        $acceptable = $this->getAcceptableContentTypes();
        return (isset($acceptable[0]) && (strpos($acceptable[0], '/json') !== false || strpos($acceptable[0], '+json') !== false));
    }
848543
def is_json(mimetype):
    
    if not mimetype:
        return False
    if ";" in mimetype:  # Allow Content-Type header to be passed
        mimetype = get_mimetype(mimetype)
    if mimetype == "application/json":
        return True
    if mimetype.startswith("application/") and mimetype.endswith("+json"):
        return True
    return False
1170578
function isJsonFile (file) {
  return file.data &&                             // The file has data
    (typeof file.data === 'string') &&            // and it's a string
    (
      mimeTypePattern.test(file.mimeType) ||      // and it has a JSON MIME type
      extensionPattern.test(file.url)             // or at least a .json file extension
    );
}
1061519
function serveRemoteJson(request, response, next) {
	if (request.path !== '/remote') {
		return next();
	}
	var options = {
		url: request.query.url,
		headers: request.query.headers
	};
	var error;

	if (!options.url || typeof options.url !== 'string') {
		error = new Error('Invalid query parameter: url');
		error.status = 400;
		return next(error);
	}

	if (options.headers && typeof options.headers !== 'string') {
		error = new Error('Invalid query parameter: headers');
		error.status = 400;
		return next(error);
	}

	options.headers = parseHeaders(options.headers);

	loadRemoteJson(options, function (error, json) {
		if (error) {
			return next(error);
		}
		response.writeHead(200, {
			'Content-Type': 'application/x-shunter+json'
		});
		response.end(JSON.stringify(json, null, 4));
	});
}