Package Exports
- strip-json-trailing-commas
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strip-json-trailing-commas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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 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