read optional JSON from filepath
@param {String} filepath
@return {Object}
516432
function (filepath) {
    var data = {};
    try {
      data = grunt.file.readJSON(filepath);
      // The concatenated file won't pass onevar
      // But our modules can
      delete data.onever;
    } catch (e) { }
    return data;
  }
757672
function getPageByPath(filePath) {
        var page = output.getPage(filePath);
        if (!page) return undefined;

        return JSONUtils.encodePage(page, summary);
    }
169044
function readSync( path, options ) {
	var file,
		opts;

	if (
		arguments.length > 1 &&
		!isString( options )
	) {
		opts = options;
	} else {
		opts = {};
	}
	opts.encoding = 'utf8';
	file = readFile.sync( path, opts );
	if ( file instanceof Error ) {
		return file;
	}
	return parse( file, opts );
}
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));
    }
  });
}
674687
function readdirAsync(filepath){
	return new Promise((resolve, reject)=>{
		fs.readdir(filepath, (err, items)=>{
			if (err) reject(err)
			else resolve(items)
		})
	})
}
585829
function parseJSON( path, content ) {

            return JSON.parse( content, function( key, value ) {

                if ( options.stripComments && key === "{{comment}}" ) return undefined;

                // Replace variables in their values

                if ( Object.keys( options.variables ).length && typeof value === "string" ) {
                    value = replaceVariables( value );
                }

                var match = ( typeof value === "string" ) ? value.match( options.parsePattern ) : null;

                if ( match ) {
                    var folderPath = getFolder( path ) || ".";
                    var fullPath = folderPath + "/" + match[ 1 ];

                    return isDirectory( fullPath ) ? parseDirectory( fullPath ) : parseFile( fullPath );
                }

                return value;

            } );
        }
192424
protected static function readJsonFile(string $jsonFilePath)
    {
        if (!file_exists($jsonFilePath)) {
            throw new Exception(
                'File '.$jsonFilePath.' not found.',
                self::ERR_FILE_NOT_FOUND
            );
        }

        $infos = json_decode(file_get_contents($jsonFilePath));
        if ($infos === null) {
            throw new Exception(
                json_last_error_msg(),
                self::ERR_JSON_PARSE
            );
        }

        return $infos;
    }
1180978
function parseFile(filePath, encoding, callback) {
	return fs.readFile(filePath, encoding, function(err, fileString) {
		if (err) {
			return callback(err);
		}

		fileString = expandIncludes(fileString, path.dirname(filePath));

		return parse(fileString, callback);
	});
}
299604
function requireJSON5(filename) {
    if ( path.extname(filename) == '' ) filename += fs.existsSync(filename + '.json5') ? '.json5' : '.json';
    try {
        return JSON5.parse(stripBOM(fs.readFileSync(filename, 'utf8')));
    }
    catch(error) {
        error.message = filename + ": " + error.message;
        throw error;
    }
}
214755
async function getDataFile(filePath) {
  ensureFileExists(filePath);
  const fileInfo = path.parse(filePath);
  try {
    switch (fileInfo.ext) {
      case '.json':
        const fileContents = await readFile(filePath, 'utf8');
        return JSON.parse(fileContents);
        break;
      case '.yml':
      case '.yaml':
        return await readYamlFile(filePath);
        break;
    }
  } catch (err) {
    log.errorAndExit('Could not getDataFile', err);
  }
}
340373
function getJSON(filepath) {
  const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
  return (new vm.Script(jsonString)).runInNewContext();
}
949087
def _ReadAppJsonFile(self, relative_path):
    
    try:
      with open(os.path.join(sys.path[0], relative_path), 'r') as f:
        return json.load(f)
    except (IOError, ValueError):
      return None
264749
function readFiles(filePath, fileType, callback) {
    if (path_1.extname(filePath) === fileType) {
        callback(filePath);
    }
    else if (fs_1.lstatSync(filePath).isDirectory()) {
        // src is directory
        var filesOrDirectories = fs_1.readdirSync(filePath);
        filesOrDirectories.map(function (fileName) {
            var fileOrDirectory = path_1.join(filePath, fileName);
            readFiles(fileOrDirectory, fileType, callback);
        });
    }
}
214356
function (filePath, cb) {
            filePath = getFileWithExt(filePath);
            if (cb) {
                fs.readFile(filePath, function (err, data) {
                    if (err) {
                        cb(err);
                    } else {
                        cb(null, data.toString('utf8'));
                    }
                })
            } else {
                try {
                    var data = fs.readFileSync(filePath);
                } catch (err) {
                    throw err;
                }
                return data.toString('utf8');
            }
        }
751854
async function readJSON(path) {
    const file = await read(path)
    const parsed = JSON.parse(file)
    return parsed
}
1272632
function (filePath) {

    // console.warn(filePath);


    var contents = String(fs.readFileSync(filePath));
    var fileExt = path.extname(filePath).substr(1);
    var fileType = fileTypes[fileExt] || fileTypes['default'];
    var returnType = /\r\n/.test(contents) ? '\r\n' : '\n';


    // console.log(fileType);

    var newContents = contents.replace(
        fileType.block,
        replaceIncludes(filePath, fileType, returnType)
    );

    // console.log(newContents);
    //  
    // return;

    if (contents !== newContents) {
        fs.writeFileSync(filePath, newContents);

        if (process.env.NODE_ENV !== 'test') {
            console.log(filePath + ' modified.');
        }
    }
}
364058
public static function loadJsonFromFile($filePath)
    {
        if (!file_exists($filePath)) {
            throw new \RuntimeException("File '{$filePath}' doesn't exist");
        }

        $content = json_decode(file_get_contents($filePath));

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonDecodeException(sprintf(
                'Cannot decode JSON from file "%s" (error: %s)',
                $filePath,
                static::lastJsonErrorMessage()
            ));
        }

        return $content;
    }