我有一本json
字典
$ cat foo.json
{
"black": "#073642",
"red": "#DC322F",
"green": "#859900",
"yellow": "#CF9A6B",
"blue": "#268BD2",
"purple": "#D33682",
"cyan": "#2AA198",
"white": "#EEE8D5",
"brightBlack": "#657B83",
"brightRed": "#D87979",
"brightGreen": "#88CF76",
"brightYellow": "#657B83",
"brightBlue": "#2699FF",
"brightPurple": "#D33682",
"brightCyan": "#43B8C3",
"brightWhite": "#FDF6E3",
"foreground": "#839496",
"background": "#002B36",
"cursorColor": "#839496"
}
我想用它来jq
打印所有的价值观在这本词典中。所以,输出应该是:
$ jq 'magic' foo.json
#073642
#DC322F
#859900
#CF9A6B
#268BD2
#D33682
#2AA198
#EEE8D5
#657B83
#D87979
#88CF76
#657B83
#2699FF
#D33682
#43B8C3
#FDF6E3
#839496
#002B36
#839496
'magic'
我正在寻找什么?
答案1
您还可以在对象上使用它,它将返回该对象的所有值。
为了获得准确的结果,您还需要jq -r
/--raw-output
省略 JSON 字符串引号:
jq -r '.[]' foo.json