query_json_stdin
v1.0.59
Published
this is description field from package.json
Downloads
11
Maintainers
Readme
This package is experimental
Do not install using npm install, just run using npx. Wrapper for jsonpath package for use in command line using pipes.
- reads stdin (standard input) for JSON string
- converts string to JSON object
- runs jsonpath on the string
- returns the first match.
- to avoid trouble, does not open a filesystem file.
Typically called from a script to determine version and name of package.json.
Example usage on a package.json file (git-bash on windows):
# get version tag:
cat package.json | npx query_json_stdin --queryStr='$..version'
# get name tag (without quotes)
cat package.json | npx query_json_stdin --queryStr='$..name'
# returns fragment of JSON. Since query returns an object, stringify() gets applied to make tags have quotes:
cat package.json | npx query_json_stdin --queryStr='$..dependencies'
# optional position argument for multi-matches. Defaults to first match:
cat package.json | npx query_json_stdin [--position=2 --position=all] --queryStr='$..name'
- Also see file2.json for more examples.
- For developing, all source code is file queryJSONstdin.js.
See comments in file about how to run js file locally.
Problem: I attempted to make a visual studio launch.json file for debugging but could not figure out how to pipe input to the run command.
Problem: tried to add a link to the file like in github markdown, but it won't work