snippetbashTip
ajson — Execute JSONPath on JSON objects. More information: <https://github.com/spyzhov/ajson#console-applic
Viewed 0 times
commandexecuteclijsonjsonpathobjectsmoreajson
Problem
How to use the
ajson command: Execute JSONPath on JSON objects. More information: <https://github.com/spyzhov/ajson#console-application>.Solution
ajson — Execute JSONPath on JSON objects. More information: <https://github.com/spyzhov/ajson#console-application>.Read JSON from a file and execute a specified JSONPath expression:
ajson '{{$..json[?(@.path)]}}' {{path/to/file.json}}Read JSON from
stdin and execute a specified JSONPath expression: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 * $}}'Code Snippets
Read JSON from a file and execute a specified JSONPath expression
ajson '{{$..json[?(@.path)]}}' {{path/to/file.json}}Read JSON from `stdin` and execute a specified JSONPath expression
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 * $}}'Context
tldr-pages: common/ajson
Revisions (0)
No revisions yet.