-
Notifications
You must be signed in to change notification settings - Fork 48
Add jpp which is an extended superset of the jp command #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rename the command from jp to jpp and nothing more.
Rebased jmespath#14 on jpp master.
Mirrors sentiments expressed here: jmespath#14 (comment) jmespath#14 (comment)
Read one or more input JSON objects into an array and apply the JMESPath expression to the resulting array.
… into a single recursively merged object This option will accumulate all output objects into a single recursively merged output object. Most of this code comes from the golang playground link posted by Roger Peppe in this "Recursively merge JSON structures" thread: https://groups.google.com/g/golang-nuts/c/nLCy75zMlS8/m/O9ZMubnKCQAJ https://play.golang.org/p/8jlJUbEJKf
This was referenced Jun 15, 2021
…nt nested lists Fixes: e7989df ("jpp: Add --accumulate, -a option which accumulates all output objects into a single recursively merged object")
zmedico
added a commit
to pipebus/jmespath.py
that referenced
this pull request
Jun 15, 2021
$ jpp --help
usage: jpp [-h] [-a] [-c] [-e EXPR_FILE] [-f FILENAME] [-s] [-u] [--ast] [expression]
jpp is an extended superset of the jp CLI for JMESPath
positional arguments:
expression
optional arguments:
-h, --help show this help message and exit
-a, --accumulate Accumulate all output objects into a single recursively merged output object.
-c, --compact Produce compact JSON output that omits nonessential whitespace.
-e EXPR_FILE, --expr-file EXPR_FILE
Read JMESPath expression from the specified file.
-f FILENAME, --filename FILENAME
The filename containing the input data. If a filename is not given then data is read from stdin.
-s, --slurp Read one or more input JSON objects into an array and apply the JMESPath expression to the resulting array.
-u, --unquoted If the final result is a string, it will be printed without quotes.
--ast Only print the AST of the parsed expression. Do not rely on this output, only useful for debugging purposes.
There's also a golang implementation in jmespath/jp#30.
If the final result is a list, unbox it into a stream of output objects that is suitable for consumption by --slurp mode. See: jqlang/jq#878
…ns --unbox now)
$ ./jpp --help
An extended superset of the jp CLI for JMESPath
Usage:
jpp [<options>] [expression] [flags]
Flags:
-a, --accumulate Accumulate all output objects into a single recursively merged output object.
--ast Only print the AST of the parsed expression. Do not rely on this output, only useful for debugging purposes.
-c, --compact Produce compact JSON output that omits nonessential whitespace.
-e, --expr-file string Read JMESPath expression from the specified file.
-f, --filename string Read input JSON from a file instead of stdin.
-h, --help show usage and exit
-R, --raw-input Read raw string input and box it as JSON strings.
-r, --raw-output If the final result is a string, it will be printed without quotes (an alias for --unquoted).
-s, --slurp Read one or more input JSON objects into an array and apply the JMESPath expression to the resulting array.
-u, --unbox If the final result is a list, unbox it into a stream of output objects that is suitable for consumption by --slurp mode.
--unquoted If the final result is a string, it will be printed without quotes.
Member
|
Thanks! This is awesome. I'd like to take some time to go through this in more detail, but looking over most of these arguments, they seem like they'd be great additions to |
Member
|
Closing out old PR. Happy to discuss features to merge back into the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the master branch of https://github.com/pipebus/jpp, which adds
jpp, an extended superset of the jp command:This command has everything that I need to replace
jqin my shell scripts.I've also added a compatible python implementation of
jppto the jpipe package, so a python implementation can be installed viapip install jpipe:pipebus/jpipe@4ca9dd3bdf36cf16b1a10a670da8f3eafd7d3388^...8acf6dc
The
jppcommand is now available on Gentoo Linux via either the app-misc/jp or app-misc/jpipe packages.I've submitted the python implementation for inclusion in jmespath/jmespath.py#224.