Validate that the call is JSON.
494406
def validate_json(f):
    """"""
    @wraps(f)
    def wrapper(*args, **kw):
        instance = args[0]
        try:
            if request.get_json() is None:
                ret_dict = instance._create_ret_object(instance.FAILURE,
                                                       None, True,
                                                       instance.MUST_JSON)
                instance.logger.error(instance.MUST_JSON)
                return jsonify(ret_dict), 400
        except BadRequest:
            ret_dict = instance._create_ret_object(instance.FAILURE, None,
                                                   True,
                                                   instance.MUST_JSON)
            instance.logger.error(instance.MUST_JSON)
            return jsonify(ret_dict), 400
        instance.logger.debug("JSON is valid")
        return f(*args, **kw)
    return wrapper
1337850
function validateTextOperationJSON (op) {
  debug('validateTextOperationJSON %o', op)
  assertErr(Array.isArray(op), Error, 'operation must be an array', { op: op })
  assertErr(op.length, Error, 'operation cannot be empty', { op: op })
  var type
  var lastType = ''
  op.forEach(function (item) {
    if (typeof item === 'string') {
      // valid
      type = 'string'
      assertErr(lastType !== type, Error, 'invalid operation: cannot have repeating ' + type + 's')
      lastType = type
      return
    } else if (typeof item === 'number') {
      var isIntegerOrZero = (item === (item | 0))
      assertErr(isIntegerOrZero, Error, 'invalid operation: numbers must be integers')
      type = item === 0
        ? 'zero'
        : item > 0
          ? 'positive integer'
          : 'negative integer'
      assertErr(lastType !== type, Error, 'invalid operation: cannot have repeating ' + type + 's')
      lastType = type
    } else {
      throw new Error('invalid operation: must be an array of strings and numbers')
    }
  })
}
351852
def is_json_compat(value):
    

    try:
        value = json.loads(value)
    except ValueError as e:
        raise ValueError('JSON decoding error: ' + str(e))
    except TypeError:
        # Check that the value can be serialized back into json.
        try:
            json.dumps(value)
        except TypeError as e:
            raise ValueError(
                'must be a JSON serializable object: ' + str(e))

    if not isinstance(value, dict):
        raise ValueError(
            'must be specified as a JSON serializable dict or a '
            'JSON deserializable string'
        )

    return True
755536
public static boolean isValidJson(String s) {
		try {
			new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(s, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
1353451
def is_json(string):
    
    if not is_full_string(string):
        return False
    if bool(JSON_WRAPPER_RE.search(string)):
        try:
            return isinstance(json.loads(string), dict)
        except (TypeError, ValueError, OverflowError):
            return False
    return False
393901
def validate_json_file(file_list):
    
    for json_file in set(file_list):
        if not json_file.endswith(".json"):
            logger.log_warning("Only JSON file format can be validated, skip: {}".format(json_file))
            continue

        logger.color_print("Start to validate JSON file: {}".format(json_file), "GREEN")

        with io.open(json_file) as stream:
            try:
                json.load(stream)
            except ValueError as e:
                raise SystemExit(e)

        print("OK")
475109
public static boolean isValidJsonStrict(String s) {
		try {
			new JSONParser(MODE_RFC4627).parse(s, FakeMapper.DEFAULT);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}
867922
def validate(request: Union[Dict, List], schema: dict) -> Union[Dict, List]:
    
    jsonschema_validate(request, schema)
    return request
327743
def json_to_model(self, model_name, j, validate=False):
        """"""
        if validate:
            self.api_spec.validate(model_name, j)
        return self.api_spec.json_to_model(model_name, j)
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
670747
function validateJSonStructure(filePath, cb) {
  fs.readFile(filePath, function(err, data) {
    if (err) {
      return cb(err);
    }

    try {
      var jsonObject = JSON.parse(data);
      cb(null, jsonObject);
    } catch (e) {
      cb('Invalid JSON file: ' + path.basename(filePath));
    }
  });
}
241438
public static function acceptJson()
    {
        $accept = self::getService('HTTP_ACCEPT');
        if (false !== strpos($accept, 'json') || false !== strpos($accept, 'javascript')) {
            return true;
        }
        return false;
    }
816923
def validate(self, obj):
        """"""
        try:
            if self.resolver is not None:
                jsonschema.validate(obj, self.schema, resolver=self.resolver)
            else:
                jsonschema.validate(obj, self.schema)
        except jsonschema.ValidationError as exc:
            raise exceptions.ValidationError(str(exc))
547546
def validate(self, data):
        '''
        '''
        try:
            self._validator.validate(data)
        except jsonschema.ValidationError as e:
            six.raise_from(ValidationError.create_from(e), e)
1127577
def validate_json(file):
    """"""
    max_file_size = current_app.config.get(
        'PREVIEWER_MAX_FILE_SIZE_BYTES', 1 * 1024 * 1024)
    if file.size > max_file_size:
        return False

    with file.open() as fp:
        try:
            json.loads(fp.read().decode('utf-8'))
            return True
        except:
            return False
1244497
def validate(token):
    """"""
    token_url = TOKEN_URL_FMT.format(token=token)
    headers = {
        'x-auth-token': token,
        'accept': 'application/json',
    }
    resp = requests.get(token_url, headers=headers)

    if not resp.status_code == 200:
        raise HTTPError(status=401)
    return resp.json()
643198
def load(self, value):
        """"""

        if not isinstance(value, str):
            raise TypeError('Expected JSON string')

        _value = json.loads(value)
        self._validate_word(value=_value)
        self.word = _value