strip-json-trailing-commas
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

strip-json-trailing-commas

npm version CI License: MIT

Strip trailing commas from JSON files.

Installation

$ yarn add strip-json-trailing-commas

or

$ npm i strip-json-trailing-commas

Usage

import stripJsonTrailingCommas from 'strip-json-trailing-commas';

console.log(stripJsonTrailingCommas(`{ "a": 1, }`));
// -> { "a": 1 }

// with options
console.log(
  stripJsonTrailingCommas(`{ "a": 1   , }`, {
    stripWhitespace: false,
  }),
);
// -> { "a": 1    }

API

stripJsonTrailingCommas(content, options?)

content

Type: string

Receive JSON string and return a string without trailing commas.

options

Type: object

stripWhitespace

  • Type: boolean
  • Default: true

Strip some whitespace between end of data and trailing commas.

License

MIT

/strip-json-trailing-commas/

    Package Sidebar

    Install

    npm i strip-json-trailing-commas

    Weekly Downloads

    1,462

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    6.54 kB

    Total Files

    8

    Last publish

    Collaborators

    • nokazn