UseWriteJsonFile
katanakit-js / useWriteJsonFile
Function: useWriteJsonFile()
Section titled “Function: useWriteJsonFile()”function useWriteJsonFile( path, data, options?): Promise<FilesystemResult<string>>;Defined in: infrastructure/filesystem/filesystem.service.ts:302
Serializes data to JSON and writes it to a file (pretty-printed by default).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path |
string |
Destination file path. |
data |
unknown |
Value to serialize (JSON.stringify rules apply). |
options? |
{ pretty?: boolean; } |
Set pretty: false for compact output. |
options.pretty? |
boolean |
- |
Returns
Section titled “Returns”Promise<FilesystemResult<string>>
Safe Result with the written path.
Example
Section titled “Example”await useWriteJsonFile("data/books.json", books);