Linux command
jello 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Filter JSON with Python
echo '[1,2,3]' | jello '[x*2 for x in _]'
Extract field
cat [data.json] | jello '_.name'
Filter array
cat [data.json] | jello '[x for x in _ if x["age"] > 30]'
Get nested value
cat [data.json] | jello '_.users[0].email'
Print JSON schema
cat [data.json] | jello -s
Output as lines
cat [data.json] | jello -l '_.items'
Load input from a file
jello -f [data.json] '_.name'
说明
jello filters JSON and JSON Lines data using Python expressions. The input data is deserialized and made available as the underscore (_) variable. Any valid Python expression can be used to transform, filter, or extract data. The tool combines jq-like filtering with Python's full expression power, including list comprehensions, dictionary methods, string operations, and standard library functions. It handles both JSON objects and JSON Lines (newline-delimited JSON) input.
参数
- -p, --pretty
- Pretty print output.
- -l, --lines
- Output JSON lines.
- -r, --raw
- Raw string output.
- -c, --compact
- Compact JSON output (no pretty printing).
- -C
- Force color output even when using pipes.
- -m, --mono
- Monochrome output (no colors).
- -n, --nulls
- Print selected null values.
- -s, --schema
- Print the JSON schema in grep-able format.
- -t, --types
- Print type annotations in schema view.
- -e
- Empty data: initialize _ as None instead of reading input.
- -i
- Initialize the data as a list for JSON Lines processing.
- -f _FILE_
- Load input data from a JSON file.
- -q _FILE_
- Load query from a file.
- -h, --help
- Display help information.
FAQ
What is the jello command used for?
jello filters JSON and JSON Lines data using Python expressions. The input data is deserialized and made available as the underscore (_) variable. Any valid Python expression can be used to transform, filter, or extract data. The tool combines jq-like filtering with Python's full expression power, including list comprehensions, dictionary methods, string operations, and standard library functions. It handles both JSON objects and JSON Lines (newline-delimited JSON) input.
How do I run a basic jello example?
Run `echo '[1,2,3]' | jello '[x*2 for x in _]'` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --pretty do in jello?
Pretty print output.