Skip to content
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

Add jpp which is an extended superset of the jp command #224

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from

Conversation

zmedico
Copy link

@zmedico zmedico commented Jun 15, 2021

$ jpp --help
usage: jpp [-h] [-a] [-c] [-e EXPR_FILE] [-f FILENAME] [-r] [-R] [-s] [-u] [--unquoted] [--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.
  -r, --raw-output      If the final result is a string, it will be printed without quotes (an alias for --unquoted).
  -R, --raw-input       Read raw string input and box it as JSON strings.
  -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.
  --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.

jamesls and others added 30 commits March 22, 2013 12:00
* release-0.0.3: (22 commits)
  Bump version to 0.0.3
  There's no tests/unit dir, just tests/
  Add travis.yml file
  Update escape compliance test to escape quotes
  Remove escape sequences
  Allow identifiers to be surrounded in double quotes
  Add proper string escaping
  Verify whitespace separator not required for '||'
  Support root level wildcards
  Simplify wildcard values parsing
  Simplify index parsing
  Add more tests to basic test spec
  Add more test cases for indices json spec
  Add a proper __repr__ to ORExpression nodes
  Change 'or' to '||'
  Add jp command line
  Don't include tests as part of package list
  Add jp command line interface
  Add support for root indexing
  Add note on pronounciation in README
  ...
* release-0.1.0: (25 commits)
  Bump version to 0.1.0
  Add with_str_method to ParseError class as well
  Map __str__ appropriately in py2/py3
  Catch case where object can't be indexed
  Improve lexer/parser error messages
  Fix example in spec
  Update docs/spec/grammar for new multiselect hash
  Update multiselect hash to require key names
  Initial commit of spec docs
  Update grammar with multiselect changes
  Update grammar for quoted char escapes
  Remove unneeded pretty_print
  Add multiselect tests for multifieldlist
  Pullup common multiselect code into base class
  Implement multiselect with array syntax
  Add tests for AST when constructing by hand
  Add more tests for root level multiselects
  Rename scalaridentifiers to nonbranched-expr
  Bug fix for scalaridentifier in multiselect
  Allow recursive scalaridentifier in multimatch expressions
  ...
* release-0.2.0:
  Bump version to 0.2.0
  Update compliance tests for projections on non list values
  Fix wildcard projection bug
  Add a JEP number to the docs
  Change JEP status to accepted
  Allow perftest to run an arbitrary directory
  Allow wildcard projections on wildcards
  Fix issue 18, indexing wildcard projections
  Fixing typo
  Adding a nested-expressions proposal
  Adding a place for JMESPath proposals
  Add another index test
  Update the spec/grammar for list flattening
  Add test for single element multiselect with flattening
  Add more tests for the flattening operator
  Make index expressions in flatten expression consistent
  Update jmespath with alternate merging behavior
  Add more indices tests
  Initial commit of flattened multiselect
  Fix unbalanced parens in grammar
* release-0.2.1:
  Bump version to 0.2.1
  Don't project non list elements in flattening operator
  Remove duplicate test case
  Update spec with the JEP 6 grammar
  Add unicode literal compliance test
  Implement JEP 6
  Add note about compliance test differences
  Update JEP to allow "_" as a valid unquoted identifier
  Add JEP 6 proposal
  Update spec/tests for wildcard syntax
  Implement JEP 1
* release-0.3.0: (48 commits)
  Bump version number to 0.3.0
  Fix bug in py26
  Update JEP with latest edits
  Adding JEP number
  Adding a functions JEP
  Document function projections in the spec
  Fix types/minor formatting errors in spec docs
  Add type info for sort/to_number/to_string
  Refactor resolver/type checker into smaller functions
  Update spec to add a note about floating numbers
  Copy over jep-3 to specification.rst
  Pull sort_by and resolve=False from functions
  Fix failing test from or expression update
  Change or statements to use true/false values rather than null
  Fix bugs in sort_by
  Final compliance tests
  Add support for variadic function
  Support type checking in argspec
  Allow projections on functions
  Initial commit of jep-3
  ...
* release-0.3.1:
  Bump version to 0.3.1
  Add docs for exptype (jep-8)
  Regen lrtables
  Initial commit of expression references
  Regen lrtables
  Add note in README about how to regen the lrtables
  Marking JEP-8 as accepted
  Add exptype to the proposals index
  Incorporate review feedback
  Initial commit of jep-8
  Add scripts to generate the lr tables
  Update perftest to run single files
  Update jp so we can actually pass the compliance tests
  Add a compliance test runner
* release-0.4.0:
  Bump version to 0.4.0
  Disallow '@' as a top level syntax
  Remove cruft that's no longer needed after pratt-jep-4
  Fix py26 test failure by using unittest2 compat import
  Add jep-4 to proposals doc
  Add docs for pipe-expression
  Switch to hand written lexer/parser
  Add sum() function
  Use proper pronunciation guide for project name
* release-0.5.0:
  Bump version to 0.5.0
  Remove unused filter_expression AST node
  Update min/max docs with new signature
  Corrected expected results for perf tests.
  Update min*/max* to support strings
  Add starts_with, ends_with, and reverse function
  Fix lexer bug when lexing an empty string
  Add missing unit tests
  Add coveragerc file
  Fix failing build, use https link for test submodule
  Cache visitor method lookups
  Initial commit that switches to an simpler AST
  Update compliance tests with latest tests
  Add jmespath.test git repo as a submodule
  Fix to_string to json dump without spaces
  Relax compliance tests for to_string
  Fix typo
  Remove function usage from pipe.json
* release-0.6.2:
  Bump version to 0.6.2
  Add changelog for 0.6.2
  Remove jmespath.test submodule
  Remove redundant error check in jp
  Raise IncompleteExpressionError where appropriate
  Use singular argument when expected arity is 1
  Add test for empty array with sort_by
  Fix invalid-type error messages
  Add a merge() function
  Add to_array function
  Fix filter projection parsing
  Sync jmespath.test submodule with latest changes
  Cleanup README, reorganize some sections
  Add another test for null check on slice projs
  Add gitter link in README
  Implement JEP-10, slice projections
* release-0.7.0:
  Bump version to 0.7.0
  Update travis CI to test from .whl files
  Add nightly to python targets
  Add additional compliance tests for raw string literals
  Add a PendingDeprecationWarning to the old string literal syntax
  Initial commit of JEP-12
  Separate compliance tests utilizing quoteless literals
  Add support for wheels
* release-0.7.1:
  Bump version to 0.7.1
  Update jp.py to not use ordereddict
  Add more perf tests
  Add deeply nested projection perf test
  Move cases into their own directory
  Update tox to run 3.4
  Remove unused imports
  Update changelog with latest changes
  Remove unused imports for 2.6
  Update setup.py with latest information
  Rename jp to jp.py for consistency
  Fix regression when parsing filters
* release-0.8.0:
  Bump version to 0.8.0
  Add changelog for latest release
  Add more map tests
  Add map() function
  Sync with latest jmespath.test repo
  Add support for using an ordered dictionary
  Process escaped single quotes
  Fix multiselect list parsing
  Actually pretty print the AST
  Rename variables to be full words
  Using a stateful lexer rather than a Scanner object
  Lexer cleanup and test fixes
  Lexer bug fixes
  Removing the computed table is just as fast but less code
  No longer using a regex based lexer
* release-0.9.3:
  Bump version to 0.9.3
  Add additional hypothesis tests for functions
  Assert more properties on parsed AST result
  Fix lexer error values
  Always create a new copy of the function table
  Add fix to changelog
  Handle scientific notation in to_number()
  Add fix to changelog
  Add tests for number type fix
  Add testing for Python 3.6 and document support
  Added fix for long and Decimal numeric types
This is the first commit of a series that will port the
golang jpp implementation to python. The jpp implementation
is in these commits which begin with the 0.1.3 tag and end
with the 0.1.3.1 tag:

pipebus/jpp@2e59b07d58b76dd7e8c1a26d5815b8eb0d3717a3^...a8ea7c9
Read one or more input JSON objects into an array and apply the
JMESPath expression to the resulting array.

Reference golang implementation:

pipebus/jpp@8a08979
… into a single recursively merged object

This option will accumulate all output objects into a single
recursively merged output object.

Reference golang implementation:

pipebus/jpp@e7989df
Reference golang implementation:

pipebus/jpp@0abe226

Fixes: 0bbc90f ("jpp: Add --accumulate, -a option which accumulates all output objects into a single recursively merged object")
$ 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.

Reference golang implementation:

pipebus/jpp@9caa261

See: jqlang/jq#878
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants