Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The JSONata documentation can be found [here](https://jsonata.org).
## Installation

```
pip install jsonata-python
pipx install jsonata-python
```

## Getting Started
Expand All @@ -39,8 +39,8 @@ A very simple start:
The CLI provides the same functionality as the [Dashjoin JSONata CLI](https://github.com/dashjoin/jsonata-cli).

```
% python3 -m jsonata.cli
usage: jsonata.cli [-h] [-v] [-e <file>] [-i <arg>] [-ic <arg>] [-f {auto,json,string}] [-o <arg>] [-oc <arg>] [-time] [-c] [-b <json-string>]
% jsonata -h
usage: jsonata [-h] [-v] [-e <file>] [-i <arg>] [-ic <arg>] [-f {auto,json,string}] [-o <arg>] [-oc <arg>] [-time] [-c] [-b <json-string>]
[-bf <file>] [-it]
[expr]

Expand Down Expand Up @@ -76,19 +76,19 @@ options:
### Examples

```
% echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli '(a & b)'
% echo '{"a":"hello", "b":" world"}' | jsonata '(a & b)'
hello world

% echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli -o helloworld.json $
% echo '{"a":"hello", "b":" world"}' | jsonata -o helloworld.json $
# helloworld.json written

% ls | python3 -m jsonata.cli $
% ls | jsonata $
helloworld.json

% ps -o pid="",%cpu="",%mem="" | python3 -m jsonata.cli '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c
% ps -o pid="",%cpu="",%mem="" | jsonata '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c
[[4105,0,0],[4646,0,0],[4666,0,0],[33696,0,0]...]

% curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | python3 -m jsonata.cli '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}'
% curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | jsonata '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}'
{
"Name": "Fred Smith",
"Cities": [
Expand All @@ -101,7 +101,7 @@ helloworld.json
]
}

% python3 -m jsonata.cli -i helloworld.json -it
% jsonata -i helloworld.json -it
Enter an expression to have it evaluated.
JSONata> (a & b)
hello world
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
requires = ["hatchling"]
build-backend = "hatchling.build"

[project.scripts]
jsonata = "jsonata.cli.__main__:main"

[project]
name = "jsonata-python"
Expand Down
2 changes: 1 addition & 1 deletion src/jsonata/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser:
"""Parses command-line arguments.
"""
parser = argparse.ArgumentParser(prog="jsonata.cli", description="Pure Python JSONata CLI")
parser = argparse.ArgumentParser(prog="jsonata", description="Pure Python JSONata CLI")
parser.add_argument(
"-v", "--version", action='version', version='%(prog)s 0.6.0')

Expand Down
Loading