UNPKG

1.14 kBMarkdownView Raw
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
5Formats 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
11curl https://raw.github.com/thlorenz/format-json-stream/master/package.json | format-json-stream | head -n 20
12
13# indent 8
14curl https://raw.github.com/thlorenz/format-json-stream/master/package.json | format-json-stream --indent 8 | head -n 20
15
16# indent 4
17curl 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
23var format = require('format-json-stream')
24
25// formats with indent 2
26process.stdin.pipe(format()).pipe(process.stdout);
27
28// formats with indent 4
29process.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