Skip to content
0

katanakit-js / useWriteJsonFile

Function: useWriteJsonFile() ​

ts
function useWriteJsonFile(
   path, 
   data, 
   options?
): Promise<FilesystemResult<string>>;

Defined in: src/infrastructure/filesystem/filesystem.service.ts:302

Serializes data to JSON and writes it to a file (pretty-printed by default).

Parameters ​

ParameterTypeDescription
pathstringDestination file path.
dataunknownValue to serialize (JSON.stringify rules apply).
options?{ pretty?: boolean; }Set pretty: false for compact output.
options.pretty?boolean-

Returns ​

Promise<FilesystemResult<string>>

Safe Result with the written path.

Example ​

ts
await useWriteJsonFile("data/books.json", books);

Released under the MIT License.