Load json file content
    
    Parameters
    ----------
    file_path:
        path to the file
    
    Raises
    ------
    TypeError
        Error with the file path
503544
def get_json_content(file_path):
    
    try:
        with open(file_path, 'r') as file:
            return json.load(file)
    except TypeError as err:
        print('Error: ', err)
        return None
1318854
def load_and_set_file_content(self, file_system_path):
        
        content = filesystem.read_file(file_system_path, storage.SCRIPT_FILE)
        if content is not None:
            self.set_script_text(content)
1078891
def load_json_object(file_name, default=None):
    
    if not os.path.isfile(file_name):
        return default

    # use utf-8-sig in case the file has a Byte Order Mark
    with codecs.open(file_name, 'r', 'utf-8-sig') as in_file:
        # read the text from the file
        content = in_file.read()

    # convert Windows line endings to Linux line endings
    content = content.replace('\r\n', '\n')

    # return a deserialized object
    return json.loads(content)
1136170
def read_file(self, path, **kwargs):
        
        # TODO support JSON here
        # TODO sphinx way of reporting errors in logs?

        parser_command = ["godocjson"]

        _ignore = kwargs.get("ignore")
        if _ignore:
            parser_command.extend(["-e", "{0}".format("|".join(_ignore))])

        parser_command.append(path)

        try:
            parsed_data = json.loads(subprocess.check_output(parser_command))
            return parsed_data
        except IOError:
            LOGGER.warning("Error reading file: {0}".format(path))
        except TypeError:
            LOGGER.warning("Error reading file: {0}".format(path))
        return None
440852
def read(self):
        
        p = os.path.join(self.path, self.name)
        try:
            with open(p) as f:
                json_text = f.read()
        except FileNotFoundError as e:
            raise JSONFileError(e) from e
        try:
            json.loads(json_text)
        except (json.JSONDecodeError, TypeError) as e:
            raise JSONFileError(f"{e} Got {p}") from e
        return json_text
1187085
def parse_config_file(config_file_path):
  
  extension = os.path.splitext(config_file_path)[1]
  if extension == '.pyc':
    raise ValueError("Skipping .pyc file as config")
  if extension == '.json':
    with open(config_file_path) as config_file:
      try:
        mapping = json.load(config_file)
      except ValueError as e:
        logger.error("Did not load json configs", e)
        raise SyntaxError('Unable to parse config file:%s due to malformed JSON. Aborting' %(config_file_path))
  elif extension == '.py':
    mapping = {}
    file_dict = load_module(config_file_path)
    for attr_name in dir(file_dict):
      if not (attr_name.startswith('_') or attr_name.startswith('__')):
        attr = getattr(file_dict, attr_name)
        if type(attr) is dict:
          mapping.update(attr)
  else:
    with open(config_file_path) as config_file:
      lines = [line.rstrip() for line in config_file if line.rstrip() != "" and not line.startswith("#")]
      mapping = parse_config_list(lines)

  return mapping
1326734
def jsonload(path, **kw):
    
    _kw = {}
    if not PY2:
        _kw['encoding'] = 'utf8'
    with io.open(path, **_kw) as fp:
        return json.load(fp, **kw)
399956
async def load(self,
                   file_path,
                   locale=None,
                   key: int = 0,
                   pos: int = 1,
                   neg: Optional[ColRanges] = None):
        

        if neg is None:
            neg: ColRanges = [(2, None)]

        await self.start(file_path, locale, kwargs={
            'key': key,
            'pos': pos,
            'neg': neg,
        })
33235
def _load_json_file_or_url(self, json_path_or_url):
        '''
        '''
        try:
            if os.path.isfile(json_path_or_url):
                with open(json_path_or_url, 'r') as f:
                    result = json.load(f)
            else:
                res = requests.get(json_path_or_url)
                res.raise_for_status()
                result = res.json()

            return result

        except (ValueError,
                requests.exceptions.RequestException) as e:
            six.raise_from(DataPackageRegistryException(e), e)
1271907
def load_file(self, path):
        
        res = None

        if not path:
            IOError("No path specified to save")

        if not os.path.isfile(path):
            raise IOError("File not found {}".format(path))

        try:
            with io.open(path, "r", encoding="utf-8") as f:
                if path.endswith(".json"):
                    res = self._load_json_file(f)
                elif path.endswith(".yaml") or path.endswith(".yml"):
                    res = self._load_yaml_file(f)
        except IOError:
            raise
        except Exception as e:
            self.exception("Failed reading {}".format(path))
            raise IOError(e)
        return res
457472
def _loadMetaFromJson(self, path):
        
        try:
            with (path / 'metadata.json').open() as infile:
                return json.load(infile)
        except FileNotFoundError:
            logger.error('Metadata does not exist at ' + str(path))
            return None
87530
def __load_settings(self):
        
        #file_path = path.relpath(settings_file_path)
        #file_path = path.abspath(settings_file_path)
        file_path = self.file_path

        try:
            self.data = json.load(open(file_path))
        except FileNotFoundError:
            print("Could not load", file_path)
729741
def load_json_from_file(file_path):
    """"""
    try:
        with open(file_path) as f:
            json_data = json.load(f)
    except ValueError as e:
        raise ValueError('Given file {} is not a valid JSON file: {}'.format(file_path, e))
    else:
        return json_data
306749
def __load_file(self, key_list) -> str:
        
        file = str(key_list[0]) + self.extension
        key_list.pop(0)
        file_path = os.path.join(self.path, file)
        if os.path.exists(file_path):
            return Json.from_file(file_path)
        else:
            raise FileNotFoundError(file_path)
245161
def read_json(file_path):
    
    try:
        with open(file_path, 'r') as f:
            config = json_tricks.load(f)
    except ValueError:
        print('    '+'!'*58)
        print('    Woops! Looks the JSON syntax is not valid in:')
        print('        {}'.format(file_path))
        print('    Note: commonly this is a result of having a trailing comma \n    in the file')
        print('    '+'!'*58)
        raise

    return config
179734
def _read_file_data(self, path):
        
        _, ext = os.path.splitext(path)
        # YAML files
        if ext in ('.yml', '.yaml'):
            try:
                with open(path) as f:
                    return yaml.safe_load(f)
            except YAMLError as e:
                raise ConfigParseError(path, e)
        # JSON files
        elif ext == '.json':
            try:
                return json.loads(open(path).read())
            except ValueError as e:
                raise ConfigParseError(path, e)
        else:
            raise ConfigParseError(path, TypeError("Unsupported file type {}".format(ext)))
801338
def load_json_file(json_file):
    
    with io.open(json_file, encoding='utf-8') as data_file:
        try:
            json_content = json.load(data_file)
        except exceptions.JSONDecodeError:
            err_msg = u"JSONDecodeError: JSON file format error: {}".format(json_file)
            logger.log_error(err_msg)
            raise exceptions.FileFormatError(err_msg)

        _check_format(json_file, json_content)
        return json_content