readJsonFile 的同步版本,读取 JSON 文件并解析为对象。
readJsonFile
JSON 解析后的类型。
文件路径。
解析后的对象。
const result = readJsonFileSync<{ name: string }>('/path/to/config.json');if (result.isOk()) { console.log(result.unwrap().name);} Copy
const result = readJsonFileSync<{ name: string }>('/path/to/config.json');if (result.isOk()) { console.log(result.unwrap().name);}
readJsonFile的同步版本,读取 JSON 文件并解析为对象。