[英]how to get some key and value from json using jq
Here is my test.json file这是我的 test.json 文件
{
"top": "0",
"sub": {
"one": "1",
"two": "2",
"three": "3"
}
}
I can use jq like this: cat test.json |我可以这样使用 jq: cat test.json | jq '.top, .sub.two'
jq '.top, .sub.two'
It returns:它返回:
"0"
"2"
Is it possible to return the key as well?是否也可以归还密钥? So like below:
所以像下面这样:
"top": "0"
"two": "2"
Thanks谢谢
For a valid JSON output:对于有效的 JSON output:
{top} + (.sub | {two})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.