• Saves JSON data to a file

    Parameters

    • data: any

      Data to save as JSON

    • filePath: string

      Path to save the JSON file

    • options: SaveAsJsonOptions = {}

      Configuration options

    Returns Promise<string>

    Promise

    const { saveAsJson } = require('./json-save');

    const data = [{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }];
    await saveAsJson(data, './output.json', { prettyPrint: true });