Skip to content

UseWriteJsonFile

katanakit-js / 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).

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 -

Promise<FilesystemResult<string>>

Safe Result with the written path.

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