@@ -21,9 +21,10 @@ JSONC is JSON with JavaScript style comments. This node module provides a scanne
21
21
Installation
22
22
------------
23
23
24
- npm install --save jsonc-parser
25
-
26
-
24
+ ```
25
+ npm install --save jsonc-parser
26
+ ```
27
+
27
28
API
28
29
---
29
30
34
35
* Creates a JSON scanner on the given text.
35
36
* If ignoreTrivia is set, whitespaces or comments are ignored.
36
37
*/
37
- export function createScanner(text : string ,ignoreTrivia : boolean = false ): JSONScanner ;
38
+ export function createScanner(text : string ,ignoreTrivia : boolean = false ): JSONScanner ;
38
39
39
40
/**
40
41
* The scanner object, representing a JSON scanner at a position in the input string.
@@ -57,7 +58,7 @@ export interface JSONScanner {
57
58
*/
58
59
getToken(): SyntaxKind ;
59
60
/**
60
- * Returns the last read token value. The value for strings is the decoded string content. For numbersits of type number, for boolean it's true or false.
61
+ * Returns the last read token value. The value for strings is the decoded string content. For numbersit's of type number, for boolean it's true or false.
61
62
*/
62
63
getTokenValue(): string ;
63
64
/**
@@ -174,6 +175,7 @@ export declare function stripComments(text: string, replaceCh?: string): string;
174
175
export declare function getLocation(text : string ,position : number ): Location ;
175
176
176
177
export declare type Segment = string | number ;
178
+ export declare type JSONPath = Segment [];
177
179
export interface Location {
178
180
/**
179
181
* The previous property key or literal value (string, number, boolean or null) or undefined.
@@ -183,13 +185,13 @@ export interface Location {
183
185
* The path describing the location in the JSON document. The path consists of a sequence strings
184
186
* representing an object property or numbers for array indices.
185
187
*/
186
- path: Segment [] ;
188
+ path: JSONPath ;
187
189
/**
188
190
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
189
191
* '*' will match a single segment, of any property name or index.
190
- * '**' will match asequece of segments or no segment, of any property name or index.
192
+ * '**' will match asequence of segments or no segment, of any property name or index.
191
193
*/
192
- matches: (patterns : Segment [] )=> boolean ;
194
+ matches: (patterns : JSONPath )=> boolean ;
193
195
/**
194
196
* If set, the location's offset is at a property key.
195
197
*/
@@ -209,7 +211,7 @@ export function findNodeAtOffset(root: Node, offset: number, includeRightBound?:
209
211
/**
210
212
* Gets the JSON path of the given JSON DOM node
211
213
*/
212
- export function getNodePath(node : Node ): JSONPath ;
214
+ export function getNodePath(node : Node ): JSONPath ;
213
215
214
216
/**
215
217
* Evaluates the JavaScript object of the given JSON DOM node
@@ -257,47 +259,47 @@ export function applyEdits(text: string, edits: Edit[]): string;
257
259
* Represents a text modification
258
260
*/
259
261
export interface Edit {
260
- /**
261
- * The start offset of the modification.
262
- */
263
- offset: number ;
264
- /**
265
- * The length of the modification. Must not be negative. Empty length represents an *insert*.
266
- */
267
- length: number ;
268
- /**
269
- * The new content. Empty content represents a *remove*.
270
- */
271
- content: string ;
262
+ /**
263
+ * The start offset of the modification.
264
+ */
265
+ offset: number ;
266
+ /**
267
+ * The length of the modification. Must not be negative. Empty length represents an *insert*.
268
+ */
269
+ length: number ;
270
+ /**
271
+ * The new content. Empty content represents a *remove*.
272
+ */
273
+ content: string ;
272
274
}
273
275
274
276
/**
275
277
* A text range in the document
276
278
*/
277
279
export interface Range {
278
- /**
279
- * The start offset of the range.
280
- */
281
- offset: number ;
282
- /**
283
- * The length of the range. Must not be negative.
284
- */
285
- length: number ;
280
+ /**
281
+ * The start offset of the range.
282
+ */
283
+ offset: number ;
284
+ /**
285
+ * The length of the range. Must not be negative.
286
+ */
287
+ length: number ;
286
288
}
287
289
288
290
export interface FormattingOptions {
289
- /**
290
- * If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
291
- */
292
- tabSize: number ;
293
- /**
294
- * Is indentation based on spaces?
295
- */
296
- insertSpaces: boolean ;
297
- /**
298
- * The default 'end of line' character
299
- */
300
- eol: string ;
291
+ /**
292
+ * If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
293
+ */
294
+ tabSize: number ;
295
+ /**
296
+ * Is indentation based on spaces?
297
+ */
298
+ insertSpaces: boolean ;
299
+ /**
300
+ * The default 'end of line' character
301
+ */
302
+ eol: string ;
301
303
}
302
304
303
305
```