gl-store-s3.js/node_modules/jmespath/jp.js

24 lines
535 B
JavaScript
Raw Normal View History

2019-05-08 11:19:12 +00:00
#!/usr/bin/env node
jmespath = require('./jmespath');
process.stdin.setEncoding('utf-8');
if (process.argv.length < 2) {
console.log("Must provide a jmespath expression.");
process.exit(1);
}
var inputJSON = "";
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if (chunk !== null) {
inputJSON += chunk;
}
});
process.stdin.on('end', function() {
var parsedInput = JSON.parse(inputJSON);
console.log(JSON.stringify(jmespath.search(parsedInput, process.argv[2])));
});