https://github.com/yammerjp/jpro
jpro is a JSON processor that can be written in a JavaScript code piece.
https://github.com/yammerjp/jpro
cli javascript jq json
Last synced: 10 months ago
JSON representation
jpro is a JSON processor that can be written in a JavaScript code piece.
- Host: GitHub
- URL: https://github.com/yammerjp/jpro
- Owner: yammerjp
- License: mit
- Created: 2022-12-01T15:57:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-02T00:20:14.000Z (over 3 years ago)
- Last Synced: 2024-01-02T14:09:37.527Z (over 2 years ago)
- Topics: cli, javascript, jq, json
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/jpro
- Size: 12.7 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
jpro
===
[](https://github.com/yammerjp/jpro/actions/workflows/ci.yaml)
[](https://opensource.org/licenses/MIT)
jpro is a JSON processor that can be written in a JavaScript code piece.
## Demo
You can immediately run the following command, if you have Node.js and npm installed
$ echo '{"name":"bob","like":["sushi","orange"]}' | npx jpro '.like'
[
"sushi",
"orange"
]
Or you can install it and run it without `npx`. This will be faster to execute.
# Install jpro to your computer
$ npm install -g jpro
# Run
$ echo '{"name":"bob","like":["sushi","orange"]}' | npx jpro '.like'
[
"sushi",
"orange"
]
## Usage
jpro is a JSON processor that can be written in a JavaScript code piece.
The command line argument code piece is interpreted as follows.
eval("output = input " + )
The following variables are available in the code piece.
- input ... JavaScript object input as JSON from STDIN
- output ... JavaScript object output as JSON to STDOUT
- stdin ... String input from STDIN
- stdout ... String output to STDOUT (Preferred over output, if not null or undefined)
## Examples
Examples of execution is shown below.
$ echo '{"name":"bob","like":["sushi","orange"]}' | npx jpro '.like'
[
"sushi",
"orange"
]
$ echo '{"name":"bob","like":["sushi","orange"]}' | npx jpro '&& Object.keys(input)'
[
"name",
"like"
]
$ echo '{"name":"bob","like":["sushi","orange"]}' | npx jpro '; stdout = input.like.join("&")'
sushi&orange
$ echo 'hello, world' | npx jpro ';stdout = stdin.toUpperCase()'
Warning: failed to parse JSON from STDIN
HELLO, WORLD
$ echo 'hello, world' | JPRO_SILENT=true npx jpro ';stdout = stdin.toUpperCase()'
HELLO, WORLD
## License
[MIT](https://github.com/yammerjp/jpro/master/LICENSE)
## Author
[yammerjp](https://github.com/yammerjp)