Check JSON format
499563
public static function isJson (string $string) : bool
    {
        if (is_numeric($string) || $string === 'true' || $string === 'false' || $string === 'null' || empty($string)) :
            return false;
        endif;

        // try to decode string
        json_decode($string);

        // check if error occured
        return json_last_error() === JSON_ERROR_NONE;
    }
236959
def get_prep_value(self, value):
        """"""
        try:
            return json.dumps(value)
        except Exception as err:
            raise ValidationError(str(err))
467682
function formatObject(o) {
		var s = String(o);
		if(s === '[object Object]' && typeof JSON !== 'undefined') {
			s = tryStringify(o, s);
		}
		return s;
	}
270732
def format_link_json(self):
        """"""
        link_json = {}
        link_json['trace_id'] = self.trace_id
        link_json['span_id'] = self.span_id
        link_json['type'] = self.type

        if self.attributes is not None:
            link_json['attributes'] = self.attributes

        return link_json
926714
def check_format(formats, input)
      formats.inject(true) do |result, (key, format)|
        format.call(input[key]) && result
      end
    end
459499
def json_format(out, graph):
    """"""
    steps = {}
    for step, deps in each_step(graph):
        steps[step.name] = {}
        steps[step.name]["deps"] = [dep.name for dep in deps]

    json.dump({"steps": steps}, out, indent=4)
    out.write("\n")
783231
function parseAndAutoValidate(json) {
  try {
    const obj = JSON.parse(json);
    return autoValidate(obj);
  } catch (error) {
    return { isValid: false, error: error };
  }
}
1369598
def check_json(json_type):
        
        try:
            str_types = (str, unicode)
        except NameError:
            str_types = (str,)

        if type(json_type) == dict:
            return json_type
        elif type(json_type) in str_types:
            return json.loads(json_type)
        else:
            raise ValueError("json_type should be a json dict or string.")
815655
def is_json(self):
        
        mt = self.mimetype
        return (
            mt == "application/json"
            or mt.startswith("application/")
            and mt.endswith("+json")
        )
1080076
def find_json(raw):
    '''
    
    '''
    ret = {}
    lines = __split(raw)
    for ind, _ in enumerate(lines):
        try:
            working = '\n'.join(lines[ind:])
        except UnicodeDecodeError:
            working = '\n'.join(salt.utils.data.decode(lines[ind:]))

        try:
            ret = json.loads(working)  # future lint: blacklisted-function
        except ValueError:
            continue
        if ret:
            return ret
    if not ret:
        # Not json, raise an error
        raise ValueError
940403
def _validate_json_format(self, filter_value, schema_validation_type):
        
        ok = False
        try:
            validators.json_schema_validation_format(filter_value, schema_validation_type)
            ok = True
        except ValueError as e:
            pass
        return ok
539798
def value2json(obj, pretty=False, sort_keys=False, keep_whitespace=True):
    
    if FIND_LOOPS:
        obj = scrub(obj, scrub_text=_keep_whitespace if keep_whitespace else _trim_whitespace())
    try:
        json = json_encoder(obj, pretty=pretty)
        if json == None:
            Log.note(str(type(obj)) + " is not valid{{type}}JSON", type=" (pretty) " if pretty else " ")
            Log.error("Not valid JSON: " + str(obj) + " of type " + str(type(obj)))
        return json
    except Exception as e:
        e = Except.wrap(e)
        try:
            json = pypy_json_encode(obj)
            return json
        except Exception:
            pass
        Log.error("Can not encode into JSON: {{value}}", value=text_type(repr(obj)), cause=e)
80759
def format_json(json_object, indent):
    
    indent_str = "\n" + " " * indent
    json_str = json.dumps(json_object, indent=2, default=serialize_json_var)
    return indent_str.join(json_str.split("\n"))
298568
def validate_json(self):
        
        if not hasattr(self, 'guidance_json'):
            return False

        checksum = self.guidance_json.get('checksum')
        contents = self.guidance_json.get('db')

        hash_key = ("{}{}".format(json.dumps(contents, sort_keys=True),
                                  self.assignment.endpoint).encode())

        digest = hashlib.md5(hash_key).hexdigest()

        if not checksum:
            log.warning("Checksum on guidance not found. Invalidating file")
            return False
        if digest != checksum:
            log.warning("Checksum %s did not match actual digest %s", checksum, digest)
            return False
        return True
1234919
def pretty_json(data):
    
    data = json.loads(data.decode('utf-8'))
    return json.dumps(data, indent=4, sort_keys=True)
15720
def pretty_json(obj):
    
    if isinstance(obj, string_types):
        try:
            obj = json.loads(obj)
        except ValueError:
            raise ClientException("`obj` is not a json string")
    json_str = json.dumps(obj, sort_keys=True, indent=2)
    print(highlight(json_str, JsonLexer(), TerminalFormatter()))
162989
def formatetfindexjson(fundbjson):
        """"""
        result = {}
        for row in fundbjson["rows"]:
            cell = row["cell"]
            fundb_id = cell["fund_id"]
            result[fundb_id] = cell
        return result