1.0.0 • Published 3 years ago

save-as-json v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Save As JSON

Save a JavaScript object, value, or JSON string to a file in browser environment.

Installation

npm install save-as-json

Usage

Example

import saveAsJSON from 'save-as-json';

const data = { key: 'value' };

// Default options
const options = {
  filename: '%timestamp',
  isJSON: false,
  replacer: null,
  space: 0,
};

saveAsJSON(data, options);

Options

filename

A string or number value.

  • %timestamp - Date.now()
  • %title - document.title
  • %date - yyyymmdd
  • %time - hhmmss

isJSON

Set to true if data is already a JSON string.

replacer and space

JSON.stringify() parameters.