【发布时间】:2021-06-01 22:06:20
【问题描述】:
下面的输出是我的 curl 查询的 json 输出。我尝试了多个 jq 过滤器来尝试获得看起来像的结果 interfaceId、供应商、地址
从我的 json/curl 输出,应用“jq”过滤器后,我只得到:
eth1
eth1
eth1
Apple
BB Technologies (Limited)
null
Ipaddress#1
Ipaddress#2
Ipaddress#3
我希望输出是:
interfaceId,vendor,addresses curl/json 返回的每条记录
有人可以帮我解决这个问题
{
"deviceId": "75c2fde3-4b5a-4faf-a24d-d8019e8911e1",
"macTable": [
{
"interfaceId": "eth1",
"addresses": [
"192.168.5.101"
],
"mac": "3c:15:c2:c3:f0:e0",
"vendor": "Apple",
"vlan": null,
"hostname": null,
"device": {
"id": null,
"connected": null,
"enabled": null,
"authorized": null,
"ipAddress": null,
"identification": {
"id": null,
"type": null
},
"overview": {
"status": "unknown"
}
},
"site": null
},
{
"interfaceId": "eth1",
"addresses": [
"192.xxx.x.1"
],
"mac": "xx:83:c4:01:ac:5d",
"vendor": "BB Technologies (Limited)",
"vlan": null,
"hostname": null,
"device": {
"id": null,
"connected": null,
"enabled": null,
"authorized": null,
"ipAddress": null,
"identification": {
"id": null,
"type": null
},
"overview": {
"status": "unknown"
}
},
"site": null
},
{
"interfaceId": "eth1",
"addresses": [
"192.xxx.x.100"
],
"mac": "9f:25:0b:4b:32:73",
"vendor": null,
"vlan": null,
"hostname": null,
"device": {
"id": null,
"connected": null,
"enabled": null,
"authorized": null,
"ipAddress": null,
"identification": {
"id": null,
"type": null
},
"overview": {
"status": "unknown"
}
},
"site": null
}
],
"pagination": {
"total": 3,
"count": 20,
"page": 1,
"pages": 1
}
}
【问题讨论】:
标签: json export-to-csv jq