JSPM

strip-json-trailing-commas

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1673
  • Score
    100M100P100Q127964F
  • License MIT

Strip trailing comma from JSON files

Package Exports

  • strip-json-trailing-commas

Readme

strip-json-trailing-commas

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 returns 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