Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add binary to parse json on the CLI

  • Loading branch information...
commit 64f5ccb5e67cb7a12e948c82f03ed2df2480acaf 1 parent 9eb9a3c
Florent Jaby authored
Showing with 23 additions and 0 deletions.
  1. +20 −0 bin/parse.js
  2. +3 −0  package.json
20 bin/parse.js
View
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+var json = require('../');
+
+
+var paths = process.argv.slice(2);
+if(!paths.length) {
+ console.error('nothing to do.');
+ process.exit(1);
+}
+
+var parser = json.createParseStream();
+paths.forEach(function(p) {
+ parser.on(p, function(value, path) {
+ console.log('%s:\t%s', path, JSON.stringify(value));
+ });
+});
+
+process.stdin.setEncoding('utf8');
+process.stdin.pipe(parser);
3  package.json
View
@@ -28,5 +28,8 @@
},
"scripts": {
"test": "nodeunit test/test-*.js"
+ },
+ "bin": {
+ "json-parse":"bin/parse.js"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.