Here is my test.json file
{
"top": "0",
"sub": {
"one": "1",
"two": "2",
"three": "3"
}
}
I can use jq like this: cat test.json | 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:
{top} + (.sub | {two})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.