Skip to content
/ jpro Public

jpro is a JSON processor that can be written in a JavaScript code piece.

License

Notifications You must be signed in to change notification settings

yammerjp/jpro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Dec 2, 2022
664e888 · Dec 2, 2022

History

15 Commits
Dec 1, 2022
Dec 1, 2022
Dec 1, 2022
Dec 2, 2022
Dec 1, 2022
Dec 1, 2022
Dec 1, 2022

Repository files navigation

jpro

CI License: 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 " + <A CODE PIECE WITH COMMAND LINE ARGUMENT>)

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

Author

yammerjp

About

jpro is a JSON processor that can be written in a JavaScript code piece.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published