jq curl与本地文件:jq:错误(在<stdin>:0处):无法索引字符串为“笑话”的字符串

时间:2019-11-30 12:03:01

标签: jq

这为什么不起作用:

curl -s http://api.icndb.com/jokes/random/3 | jq '.[] | .joke'
jq: error (at <stdin>:0): Cannot index string with string "joke"

这是什么时候

jq '.[] | .joke' jokes.json                                   
"Chuck Norris hosting is 101% uptime guaranteed."
"The crossing lights in Chuck Norris's home town say &quot;Die slowly&quot; and &quot;die quickly&quot;. They each have a picture of Chuck Norris punching or kicking a pedestrian."
"When in a bar, you can order a drink called a &quot;Chuck Norris&quot;. It is also known as a &quot;Bloody Mary&quot;, if your name happens to be Mary."

1 个答案:

答案 0 :(得分:2)

curl -s http://api.icndb.com/jokes/random/3 | jq '.value[].joke'

在这里工作正常。