jsf

json-stream-formatter

A command line tool and through stream for formatting streams of JSON objects into a text stream.

Showing:

Popularity

Downloads/wk

1

GitHub Stars

2

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

5

Size (min+gzip)

17.3KB

License

GPL-2.0-or-later

Type Definitions

Tree-Shakeable

No?

Categories

Readme

JSON Event Stream Formatter

Build Status Coverage Status

Usage

CLI usage

By default json-stream-format pretty prints a json stream. If you want to use a more specific format you can use the --format (-f) parameter and specify the format. Place object keys to include inside double curly {{something}} brackets.

Example

cat test/fixtures/example.log | json-stream-format --format '{{time|date("h:m:s")|blue}}: {{msg|green}}'

You can also leave off the format, non-parameter arguments will be used as formats by default.

cat test/fixtures/example.log | json-stream-format '{{time|date("h:m:s")|blue}}: {{msg|green}}'

Node.js usage

Formatting

var jsf = require('json-stream-formatter');
var es = require('event-stream');
process.stdin
  .pipe(es.split())
  .pipe(es.parse())
  .pipe(jsf.format('{{time|date("d/m/y h:m:s")|blue}}: {{msg}}'))
  .pipe(process.stdout);

Pretty printing

var jsf = require('json-stream-formatter');
var es = require('event-stream');
process.stdin
  .pipe(es.split())
  .pipe(es.parse())
  .pipe(jsf.prettyPrint())
  .pipe(process.stdout);

Format sytnax

The formatter utilizes twig.js for foratting the json event messages. Available filters can be found in the twig.js implementation notes. In addition chalk-twig-filters are added to provide all of the chalk colors as twig filters. These are the color filters used in the examples above.

Installation

sudo npm install -g json-stream-formatter

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial