-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Is there an existing issue for this?
- I have searched for existing issues and did not find anything like this
Describe the enhancement
We recommend adding a jval(1) tool to allow one to analyse, transform and selectively extract data from a JSON document.
This tool should use the XPath for JSON model.
FYI: XPath is a general model that allows one to analyse, transform and selectively extract data from XML. The above mentioned XPath for JSON applies that model to JSON: often called JSONPath.
There exist several implementations JSONPath. For example, the "outer repo" uses JSONPath.sh as a bash(1) implementation of JSONPath. And while that implementation of very slow, it is used by tools such as bin/jval-wrapper.sh and bin/jfmt-wrapper.sh and bin/jprint-wrapper.sh.
To speed up the above mentioned wrapper tools, a jval(1) tool needs to be created that uses the same XPath for JSON model used by the very slow JSONPath.sh.
Relevant images, screenshots or other files
We recommend the following command line for jval(1):
usage: jval [-h] [-v level] [-V] [--use-jparse] file.json pattern
-h print help message and exit
-v level set verbosity level (def level: 0)
-V print version string and exit
--use-jparse Do nothing: this option is a simple way to verify this tool came from the jparse toolset.
NOTE: Other command line options are being considered. This command line model will be updated later.
file.json JSON input file
If file.json is - (dash) read from standard input.
If file.json is . (dot) do not read any file, perform an internal test and exit accordingly.
pattern JPATH Expression
A good resource for JSONPath Syntax and Semantics is RFC9535.
NOTE: We are still considering additional command line options. One such possibility comes from the jsonpath-cli facility and some of its jpp(1) options. See also the jsonpath-cli repo.
Another XPath for JSON implementation and possible command line model is jsp.
Relevant links
See RFC9535 for an overview of JSONPath Syntax and Semantics.
The XPath of JSON is one of the original descriptions for how XPath would apply to JSON.
See How to use JSON Path for examples of how to use jpp(1) (see jsonpath-cli).
This issue was inspired by the obsolete issue #523 from the mkiocccentry repo.
Anything else?
We will fill out this section as the above command line model is improved.
Stay tuned for more updates!