小编Rya*_*n R的帖子

从 curl API 请求解析 JSON 数据

我正在使用 Shodan 的 API https://developer.shodan.io/api来获取我当前的网络警报。我想用 jq 解析出警报的 id。

卷曲请求是 curl -X GET -i https://api.shodan.io/shodan/alert/info?key={API KEY}

该请求的输出是格式如下的 json 数据:

[
 {
  "name": "Test Alert",
  "created": "2017-01-09T21:53:17.104000",
  "expires": 0,
  "expiration": null,
  "filters": {
   "ip": [
    "198.20.88.870"
   ]
  },
  "id": "HKVGCP1WD79Z7W2T",
  "size": 1
 }
]
Run Code Online (Sandbox Code Playgroud)

使用curl -X GET -i https://api.shodan.io/shodan/alert/info?key={API KEY} | jq '.id'给出以下错误:

"parse error: Invalid numeric literal at line 1, column 9"
Run Code Online (Sandbox Code Playgroud)

curl json jq

2
推荐指数
1
解决办法
7868
查看次数

标签 统计

curl ×1

jq ×1

json ×1