Home > @momentum-design/common > Json > write

Json.write() method

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Write the provided data to the target path formatted as json.

Signature:

static write(target: string, data: any, tabSpacing?: number): Promise<void>;

Parameters

ParameterTypeDescription
targetstringDestination file for the provided json object to be written to.
dataanyData to write to the target destination.
tabSpacingnumber(Optional) Spacing to use for indents within the output file.

Returns:

Promise<void>

  • Promise that resolves once the file is successfully written.

Remarks

This method also ammends an additional \n character to the end of the provided data as a string in order to follow our “new line at end-of-file” rule.