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