2020-07-17 18:43:24 +01:00
|
|
|
# ajson
|
|
|
|
|
2024-04-25 23:58:21 +01:00
|
|
|
> Execute JSONPath on JSON objects.
|
2020-07-17 18:43:24 +01:00
|
|
|
> More information: <https://github.com/spyzhov/ajson>.
|
|
|
|
|
|
|
|
- Read JSON from a file and execute a specified JSONPath expression:
|
|
|
|
|
|
|
|
`ajson '{{$..json[?(@.path)]}}' {{path/to/file.json}}`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Read JSON from `stdin` and execute a specified JSONPath expression:
|
2020-07-17 18:43:24 +01:00
|
|
|
|
|
|
|
`cat {{path/to/file.json}} | ajson '{{$..json[?(@.path)]}}'`
|
|
|
|
|
|
|
|
- Read JSON from a URL and evaluate a specified JSONPath expression:
|
|
|
|
|
|
|
|
`ajson '{{avg($..price)}}' '{{https://example.com/api/}}'`
|
|
|
|
|
|
|
|
- Read some simple JSON and calculate a value:
|
|
|
|
|
|
|
|
`echo '{{3}}' | ajson '{{2 * pi * $}}'`
|