main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
807 bytes
|
Line | |
---|
1 | declare namespace stripJsonComments {
|
---|
2 | interface Options {
|
---|
3 | /**
|
---|
4 | Replace comments with whitespace instead of stripping them entirely.
|
---|
5 |
|
---|
6 | @default true
|
---|
7 | */
|
---|
8 | readonly whitespace?: boolean;
|
---|
9 | }
|
---|
10 | }
|
---|
11 |
|
---|
12 | /**
|
---|
13 | Strip comments from JSON. Lets you use comments in your JSON files!
|
---|
14 |
|
---|
15 | 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.
|
---|
16 |
|
---|
17 | @param jsonString - Accepts a string with JSON.
|
---|
18 | @returns A JSON string without comments.
|
---|
19 |
|
---|
20 | @example
|
---|
21 | ```
|
---|
22 | const json = `{
|
---|
23 | // Rainbows
|
---|
24 | "unicorn": "cake"
|
---|
25 | }`;
|
---|
26 |
|
---|
27 | JSON.parse(stripJsonComments(json));
|
---|
28 | //=> {unicorn: 'cake'}
|
---|
29 | ```
|
---|
30 | */
|
---|
31 | declare function stripJsonComments(
|
---|
32 | jsonString: string,
|
---|
33 | options?: stripJsonComments.Options
|
---|
34 | ): string;
|
---|
35 |
|
---|
36 | export = stripJsonComments;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.