Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments)
  2. > Strip comments from JSON. Lets you use comments in your JSON files!
  3. This is now possible:
  4. ```js
  5. {
  6. // rainbows
  7. "unicorn": /* ❤ */ "cake"
  8. }
  9. ```
  10. It will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error positions to remain as close as possible to the original source.
  11. Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.
  12. ## Install
  13. ```
  14. $ npm install --save strip-json-comments
  15. ```
  16. ## Usage
  17. ```js
  18. const json = '{/*rainbows*/"unicorn":"cake"}';
  19. JSON.parse(stripJsonComments(json));
  20. //=> {unicorn: 'cake'}
  21. ```
  22. ## API
  23. ### stripJsonComments(input, [options])
  24. #### input
  25. Type: `string`
  26. Accepts a string with JSON and returns a string without comments.
  27. #### options
  28. ##### whitespace
  29. Type: `boolean`
  30. Default: `true`
  31. Replace comments with whitespace instead of stripping them entirely.
  32. ## Related
  33. - [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module
  34. - [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS
  35. ## License
  36. MIT © [Sindre Sorhus](http://sindresorhus.com)