method to check if a input field contains valid json and set visual accordingly.
486443
function validateInputAsJson() {
  if (this.value) {
    try {
      JSON.parse(this.value);
      setValidationClasses(this, true);
    }
    catch(e) {
      setValidationClasses(this, false);
    }
  }
  else {
    setValidationClasses(this, false)
  }
}
606163
def validate_json_field(dist, attr, value):
    

    try:
        is_json_compat(value)
    except ValueError as e:
        raise DistutilsSetupError("%r %s" % (attr, e))

    return True
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
285945
function validateGeoJson(geoJson) {
  if (!geoJson)
    throw new Error('No geojson passed');

  if (geoJson.type !== 'FeatureCollection' &&
    geoJson.type !== 'GeometryCollection' &&
    geoJson.type !== 'MultiLineString' &&
    geoJson.type !== 'LineString' &&
    geoJson.type !== 'Feature'
  )
    throw new Error(`Invalid input type '${geoJson.type}'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature`);
}
360085
def validate_contents(file_contents):
    """"""
    for name, contents in file_contents.items():
        if os.path.splitext(name)[1] != '.ipynb':
            continue
        if not contents:
            return False
        try:
            json_object = json.loads(contents)
        except ValueError:
            return False
    return True
9139
def validate_json(data: str):
    
    result = None
    try:
        result = json.loads(data)
    except ValueError as error:
        log(ERROR, "invalid json: %s", error)

    return result
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
871141
def validate(obj, schema):
        
        if isinstance(obj, str):
            obj = json.loads(obj)
        return JsonValidator(schema)._validate(obj)
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'])
1239831
protected void checkJsonBeanValidator() {
        final Class<?> returnType = executeMethod.getReturnType();
        if (!JsonResponse.class.isAssignableFrom(returnType)) {
            return;
        }
        final Type genericReturnType = executeMethod.getGenericReturnType();
        if (genericReturnType == null || !(genericReturnType instanceof ParameterizedType)) { // just in case
            return;
        }
        final Class<?> jsonBeanType = DfReflectionUtil.getGenericFirstClass(genericReturnType);
        if (jsonBeanType == null) { // just in case
            return;
        }
        if (Collection.class.isAssignableFrom(jsonBeanType)) { // e.g. JsonResponse<List<SeaBean>>
            final Type[] resopnseArgTypes = DfReflectionUtil.getGenericParameterTypes(genericReturnType);
            if (resopnseArgTypes.length > 0) { // just in case
                final Class<?> elementBeanType = DfReflectionUtil.getGenericFirstClass(resopnseArgTypes[0]);
                if (elementBeanType != null && mayBeJsonBeanType(elementBeanType)) { // just in case
                    doCheckJsonBeanValidator(elementBeanType, Collections.emptyMap()); // can check JsonResponse<List<SeaBean>>
                }
            }
        } else if (mayBeJsonBeanType(jsonBeanType)) { // e.g. JsonResponse<SeaBean>, JsonResponse<WholeBean<SeaBean>>
            doCheckJsonBeanValidator(jsonBeanType, prepareJsonBeanGenericMap(genericReturnType, jsonBeanType));
        }
    }
540181
function isValidJSONPointer(pointer) {
    // Validates JSON pointer string.

    if (!isString(pointer)) {
      // If it's not a string, it obviously is not valid.
      return false;
    }

    if ('' === pointer) {
      // If it is string and is an empty string, it's valid.
      return true;
    }

    // If it is non-empty string, it must match spec defined format.
    // Check Section 3 of specification for concrete syntax.
    return NON_EMPTY_POINTER_REGEXP.test(pointer);
  }
582792
def fromJSON(value):
        """"""
        if isinstance(value, str):
            value = json.loads(value)
        elif isinstance(value, dict): pass
        else:
            raise AttributeError("Invalid input")
        return Extension(typeName=value['typeName'],
                         capabilities=value['capabilities'],
                         enabled=value['enabled'] == "true",
                         maxUploadFileSize=value['maxUploadFileSize'],
                         allowedUploadFileType=value['allowedUploadFileTypes'],
                         properties=value['properties'])
307893
public static boolean isValidJson(String jsonStr) {
        if (jsonStr == null || jsonStr.trim()
                .equals("")) {
            return false;
        }
        try {
            Object object = JSON.parse(jsonStr);
            if (object instanceof JSONObject) {
                return true;
            } else if (object instanceof JSONArray) {
                return true;
            }
        } catch (Throwable e) {
            return false;
        }
        return false;
    }
1241147
def validate(in_, options=None):
    
    obj_json = json.load(in_)

    results = validate_parsed_json(obj_json, options)

    return results
34692
def assert_valid_input(cls, tag):
        """"""

        # Fail on unexpected types.
        if not cls.is_tag(tag):
            raise TypeError("Expected a BeautifulSoup 'Tag', but instead recieved type {}".format(type(tag)))
706745
public static boolean isValidJsonValue( Object value ) {
      if( JSONNull.getInstance()
            .equals( value ) || value instanceof JSON || value instanceof Boolean
            || value instanceof Byte || value instanceof Short
            || value instanceof Integer || value instanceof Long || value instanceof Double
            || value instanceof BigInteger || value instanceof BigDecimal
            || value instanceof JSONFunction || value instanceof JSONString
            || value instanceof String ){
         return true;
      }
      return false;
   }
1281425
function _validateTypeValue(v) {
  // can be a string or an empty object
  if(_isString(v) || _isEmptyObject(v)) {
    return;
  }

  // must be an array
  var isValid = false;
  if(_isArray(v)) {
    // must contain only strings
    isValid = true;
    for(var i = 0; i < v.length; ++i) {
      if(!(_isString(v[i]))) {
        isValid = false;
        break;
      }
    }
  }

  if(!isValid) {
    throw new JsonLdError(
      'Invalid JSON-LD syntax; "@type" value must a string, an array of ' +
      'strings, or an empty object.', 'jsonld.SyntaxError', {value: v});
  }
}