jq curl vs 本地文件: jq: 错误 <stdin>(在 :0): 无法使用字符串"joke"索引字符串



为什么这不起作用:

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."
curl -s http://api.icndb.com/jokes/random/3 | jq '.value[].joke'

在这里工作正常。

最新更新