1.0.59 • Published 1 year ago
query_json_stdin v1.0.59
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
About npx and how it knows what to do:
- When "npx query_json_stdin" is run on a terminal window, npmjs gets searched for the package query_json_stdin.
Inside this package, file package.json is read to get this line:"bin": "queryJSONstdin.js",
This tells npx to run file queryJSONstdin.js on your terminal. This file can also invoke a bundle.js and be the entry for a really big application. - The section:
is also examined and packages downloaded before running if needed."dependencies": { "jsonpath": "^1.1.1", "yargs": "^17.7.2" },
- The downloaded npm packages go into the global location. On windows it's C:\Users\zzz\AppData\Local\npm-cache_npx\xxxx\node_modules
1.0.59
1 year ago
1.0.55
1 year ago
1.0.53
1 year ago
1.0.58
1 year ago
1.0.57
1 year ago
1.0.56
1 year ago
1.0.49
1 year ago
1.0.51
1 year ago
1.0.50
1 year ago
1.0.52
1 year ago
1.0.48
1 year ago
1.0.47
1 year ago
1.0.46
1 year ago
1.0.45
1 year ago
1.0.44
1 year ago
1.0.23
1 year ago
1.0.19
1 year ago
1.0.17
1 year ago
1.0.16
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago