Skip to content

@longmo-utils/node / writeJson

Function: writeJson()

ts
function writeJson(
   filePath, 
   data, 
spaces): Promise<void>;

将数据写入 JSON 文件

Parameters

ParameterTypeDefault valueDescription
filePathstringundefined文件路径
dataanyundefined要写入的数据
spacesnumber2缩进空格数

Returns

Promise<void>

Example

ts
await writeJson('./config.json', { name: 'test' })

Released under the MIT License.