是否有一个 `jq` 命令行工具或包装器可以让您交互式地探索类似于 `jmespath.terminal` 的 `jq`
Is there a `jq` command line tool or wrapper which lets you interactively explore `jq` similar to `jmespath.terminal`
jq
是一个轻量级且灵活的命令行 JSON 处理器。
https://stedolan.github.io/jq/
是否有 jq
命令行工具或包装器可让您通过管道输出并交互式探索 jq
,在一个窗格中输入 JSON 并交互式更新结果在另一个窗格中,类似于 jmespath.terminal
?
我正在寻找类似于 JMESPath 终端的东西 jpterm
"JMESPath exploration tool in the terminal"
https://github.com/jmespath/jmespath.terminal
我找到了这个项目jqsh
,但它没有维护,而且在我使用它时似乎产生了很多错误。
https://github.com/bmatsuo/jqsh
我用过 https://jqplay.org/,它是一个很棒的基于网络的 jq
学习工具。但是,我希望能够在 shell 中将命令的 json 输出通过管道传输到交互式 jq
中,这样我就可以探索和试验 jq
命令.
提前致谢!
您可能必须 roll-your-own。
当然,jq 本身是交互式的,如果您在不指定任何 JSON 输入的情况下调用它,它将以交互方式处理 STDIN。
如果您想将相同的数据提供给多个程序,您可以轻松地编写自己的包装器。在 github 那边,a bash script named jqplay 有一些花里胡哨的东西。例如,如果输入命令以 | 开头然后将最近的结果用作输入。
示例 1
./jqplay -c spark.json
Enter a jq filter (possibly beginning with "|"), or blank line to terminate:
.[0]
{"name":"Paddington","lovesPandas":null,"knows":{"friends":["holden","Sparky"]}}
.[1]
{"name":"Holden"}
| .name
"Holden"
| .[0:1]
"H"
| length
1
.[1].name
"Holden"
Bye.
示例 2
./jqplay -n
Enter a jq filter (possibly beginning and/or ending with "|"), or blank line to terminate:
?
An initial | signifies the filter should be applied to the previous jq
output.
A terminating | causes the next line that does not trigger a special
action to be appended to the current line.
Special action triggers:
:exit # exit this script, also triggered by a blank line
:help # print this help
:input PATHNAME ...
:options OPTIONS
:save PN # save the most recent output in the named file provided
it does not exist
:save! PN # save the most recent output in the named file
:save # save to the file most recently specified by a :save command
:show # print the OPTIONS and PATHNAMEs currently in effect
:! PN # equivalent to the sequence of commands
:save! PN
:input PN
? # print this help
# # ignore this line
1+2
3
:exit
Bye.
n.b。我不清楚它如何严格遵循 jq 语法和功能集
我一直在使用 jiq
,我非常满意。
https://github.com/fiatjaf/jiq
您可以使用 jq 过滤查询以交互方式向下钻取。
jiq
在内部使用 jq
,它要求您在 PATH 中包含 jq
。
使用 aws
cli
aws ec2 describe-regions --region-names us-east-1 us-west-1 | jiq
jiq
输出
[Filter]> .Regions
{
"Regions": [
{
"Endpoint": "ec2.us-east-1.amazonaws.com",
"RegionName": "us-east-1"
},
{
"Endpoint": "ec2.us-west-1.amazonaws.com",
"RegionName": "us-west-1"
}
]
}
如果您正在使用(或愿意)使用 Emacs,那么 JQ 模式允许您在当前 JSON 文档缓冲区上以交互方式 运行 JQ 过滤器:
有一个新的:https://github.com/PaulJuliusMartinez/jless
JLess is a command-line JSON viewer designed for reading, exploring, and searching through JSON data.
JLess will pretty print your JSON and apply syntax highlighting.
Expand and collapse Objects and Arrays to grasp the high- and low-level structure of a JSON document. JLess has a large suite of vim-inspired commands that make exploring data a breeze.
JLess supports full text regular-expression based search. Quickly find the data you're looking for in long String values, or jump between values for the same Object key.
jq
是一个轻量级且灵活的命令行 JSON 处理器。
https://stedolan.github.io/jq/
是否有 jq
命令行工具或包装器可让您通过管道输出并交互式探索 jq
,在一个窗格中输入 JSON 并交互式更新结果在另一个窗格中,类似于 jmespath.terminal
?
我正在寻找类似于 JMESPath 终端的东西 jpterm
"JMESPath exploration tool in the terminal"
https://github.com/jmespath/jmespath.terminal
我找到了这个项目jqsh
,但它没有维护,而且在我使用它时似乎产生了很多错误。
https://github.com/bmatsuo/jqsh
我用过 https://jqplay.org/,它是一个很棒的基于网络的 jq
学习工具。但是,我希望能够在 shell 中将命令的 json 输出通过管道传输到交互式 jq
中,这样我就可以探索和试验 jq
命令.
提前致谢!
您可能必须 roll-your-own。
当然,jq 本身是交互式的,如果您在不指定任何 JSON 输入的情况下调用它,它将以交互方式处理 STDIN。
如果您想将相同的数据提供给多个程序,您可以轻松地编写自己的包装器。在 github 那边,a bash script named jqplay 有一些花里胡哨的东西。例如,如果输入命令以 | 开头然后将最近的结果用作输入。
示例 1
./jqplay -c spark.json
Enter a jq filter (possibly beginning with "|"), or blank line to terminate:
.[0]
{"name":"Paddington","lovesPandas":null,"knows":{"friends":["holden","Sparky"]}}
.[1]
{"name":"Holden"}
| .name
"Holden"
| .[0:1]
"H"
| length
1
.[1].name
"Holden"
Bye.
示例 2
./jqplay -n
Enter a jq filter (possibly beginning and/or ending with "|"), or blank line to terminate:
?
An initial | signifies the filter should be applied to the previous jq
output.
A terminating | causes the next line that does not trigger a special
action to be appended to the current line.
Special action triggers:
:exit # exit this script, also triggered by a blank line
:help # print this help
:input PATHNAME ...
:options OPTIONS
:save PN # save the most recent output in the named file provided
it does not exist
:save! PN # save the most recent output in the named file
:save # save to the file most recently specified by a :save command
:show # print the OPTIONS and PATHNAMEs currently in effect
:! PN # equivalent to the sequence of commands
:save! PN
:input PN
? # print this help
# # ignore this line
1+2
3
:exit
Bye.
n.b。我不清楚它如何严格遵循 jq 语法和功能集
我一直在使用 jiq
,我非常满意。
https://github.com/fiatjaf/jiq
您可以使用 jq 过滤查询以交互方式向下钻取。
jiq
在内部使用 jq
,它要求您在 PATH 中包含 jq
。
使用 aws
cli
aws ec2 describe-regions --region-names us-east-1 us-west-1 | jiq
jiq
输出
[Filter]> .Regions
{
"Regions": [
{
"Endpoint": "ec2.us-east-1.amazonaws.com",
"RegionName": "us-east-1"
},
{
"Endpoint": "ec2.us-west-1.amazonaws.com",
"RegionName": "us-west-1"
}
]
}
如果您正在使用(或愿意)使用 Emacs,那么 JQ 模式允许您在当前 JSON 文档缓冲区上以交互方式 运行 JQ 过滤器:
有一个新的:https://github.com/PaulJuliusMartinez/jless
JLess is a command-line JSON viewer designed for reading, exploring, and searching through JSON data.
JLess will pretty print your JSON and apply syntax highlighting.
Expand and collapse Objects and Arrays to grasp the high- and low-level structure of a JSON document. JLess has a large suite of vim-inspired commands that make exploring data a breeze.
JLess supports full text regular-expression based search. Quickly find the data you're looking for in long String values, or jump between values for the same Object key.