@@ -84,8 +84,8 @@ By default, `jsonlint` will either report a syntax error with details or pretty-
84
84
-E, --extensions [ext] file extensions to process for directory walk
85
85
(default: ["json","JSON"])
86
86
-i, --in-place overwrite the input files
87
- -t, --indent [char] characters to use for indentation
88
- (default: " " )
87
+ -t, --indent [num| char] number of spaces or specific characters
88
+ to use for indentation (default: 2 )
89
89
-c, --compact compact error display
90
90
-M, --mode [mode] set other parsing flags according to a format
91
91
type (default: "json")
@@ -190,7 +190,7 @@ You can parse a JSON string to an array of tokens and print it back to a string
190
190
const { tokenize } = require (' @prantlf/jsonlint' )
191
191
const tokens = tokenize (' string with JSON data' , { rawTokens: true })
192
192
const { print } = require (' @prantlf/jsonlint/lib/printer' )
193
- const output = print (tokens, { indent: ' ' })
193
+ const output = print (tokens, { indent: 2 })
194
194
```
195
195
196
196
The [ ` tokenize ` ] ( #tokenizing ) method accepts options in the second optional parameter. See the [ ` tokenize ` ] ( #tokenizing ) method above for more information.
@@ -199,7 +199,7 @@ The [`print`](#pretty-printing) method accepts an object `options` as the second
199
199
200
200
| Option | Description |
201
201
| --------------------------- | ------------------------------------------------------- |
202
- | ` indent ` | whitespace characters to be used as an indentation unit |
202
+ | ` indent ` | count of spaces or the specific characters to be used as an indentation unit |
203
203
| ` pruneComments ` | will omit all tokens with comments |
204
204
| ` stripObjectKeys ` | will not print quotes around object keys which are JavaScript identifier names |
205
205
@@ -213,13 +213,13 @@ print(tokens, {})
213
213
// (Just introduce line breaks.)
214
214
print (tokens, { indent: ' ' })
215
215
// Print to multiple lines with object and array indentation. (Just like
216
- // `JSON.stringify(json, undefined, ' ' )` would do it, but retaining comments.)
217
- print (tokens, { indent: ' ' })
216
+ // `JSON.stringify(json, undefined, 2 )` would do it, but retaining comments.)
217
+ print (tokens, { indent: 2 })
218
218
// Print to multiple lines with object and array indentation, omit comments.
219
219
// (Just like `JSON.stringify(json, undefined, ' ')` would do it.)
220
220
print (tokens, { indent: ' ' , pruneComments: true })
221
221
// Print to multiple lines with indentation enabled and JSON5 object keys.
222
- print (tokens, { indent: ' ' , stripObjectKeys: true })
222
+ print (tokens, { indent: ' \t ' , stripObjectKeys: true })
223
223
```
224
224
225
225
### Tokenizing
@@ -305,8 +305,9 @@ ${reason}`)
305
305
306
306
Copyright (C) 2012-2019 Zachary Carter, Ferdinand Prantl
307
307
308
- Licensed under the MIT license .
308
+ Licensed under the [ MIT License ] .
309
309
310
+ [ MIT License ] : http://en.wikipedia.org/wiki/MIT_License
310
311
[ pure JavaScript version ] : http://prantlf.github.com/jsonlint/
311
312
[ jsonlint.com ] : http://jsonlint.com
312
313
[ JSON ] : https://tools.ietf.org/html/rfc8259
0 commit comments