← 返回命令列表

Linux command

ajson 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Query

ajson '$.store.book[*].author' [file.json]

Example

echo '{"name":"John"}' | ajson '$.name'

Example

ajson '$.store.book[?(@.price < 10)]' [file.json]

Example

ajson -m '$.name' [file.jsonl]

Evaluate

ajson 'avg($..price)' [file.json]

说明

ajson is a command-line tool written in Go for querying and evaluating JSON data using JSONPath expressions. It reads JSON from a file or stdin and supports filters, wildcards, recursive descent, and evaluation functions such as avg, sum, length, first, last, and math functions. JSONPath syntax is similar to XPath for XML, with $ representing the root object, . for property access, [] for array indexing or filtering, and .. for recursive descent.

参数

jsonpath
JSONPath expression or evaluation string to evaluate.
file
Path to JSON file (reads stdin if omitted).
-m, --multiline
Read input as multiline JSON, where each line is a separate valid JSON object.
-q, --quiet
Do not print errors to stderr.

FAQ

What is the ajson command used for?

ajson is a command-line tool written in Go for querying and evaluating JSON data using JSONPath expressions. It reads JSON from a file or stdin and supports filters, wildcards, recursive descent, and evaluation functions such as avg, sum, length, first, last, and math functions. JSONPath syntax is similar to XPath for XML, with $ representing the root object, . for property access, [] for array indexing or filtering, and .. for recursive descent.

How do I run a basic ajson example?

Run `ajson '$.store.book[*].author' [file.json]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does jsonpath do in ajson?

JSONPath expression or evaluation string to evaluate.