1 | # format-json-stream [![build status](https://secure.travis-ci.org/thlorenz/format-json-stream.png)](http://travis-ci.org/thlorenz/format-json-stream)
|
2 |
|
3 | [![browser support](https://ci.testling.com/thlorenz/format-json-stream.png)](https://ci.testling.com/thlorenz/format-json-stream)
|
4 |
|
5 | Formats a JSON stream to make it more readable by adding proper indentation and newlines.
|
6 |
|
7 | ## As Commandline Tool
|
8 |
|
9 | ```sh
|
10 | # default indent 2
|
11 | curl https://raw.github.com/thlorenz/format-json-stream/master/package.json | format-json-stream | head -n 20
|
12 |
|
13 | # indent 8
|
14 | curl https://raw.github.com/thlorenz/format-json-stream/master/package.json | format-json-stream --indent 8 | head -n 20
|
15 |
|
16 | # indent 4
|
17 | curl https://raw.github.com/thlorenz/format-json-stream/master/package.json | format-json-stream -i 4 | head -n 20
|
18 | ```
|
19 |
|
20 | ## As Library
|
21 |
|
22 | ```js
|
23 | var format = require('format-json-stream')
|
24 |
|
25 | // formats with indent 2
|
26 | process.stdin.pipe(format()).pipe(process.stdout);
|
27 |
|
28 | // formats with indent 4
|
29 | process.stdin.pipe(format(4)).pipe(process.stdout);
|
30 | ```
|
31 |
|
32 | ## Installation
|
33 |
|
34 | npm install format-json-stream
|
35 |
|
36 | # or as cli tool
|
37 |
|
38 | npm install -g format-json-stream
|