jq - 如果值不为null,如何输出文档?

问题描述 投票:0回答:1

我试图找到如何从finalStatus!= null中提取以下数组中的文档的方法。

我尝试过select(.[].finalStatus != null)but没有成功。我仍然得到两条线。

[
  {
    "_type": "http",
    "uri": "/rest/eFulfillment/V1/stock/5117855/OHK30",
    "status": 200,
    "statustext": "OK",
    "method": "GET",
    "vhost": null,
    "wafStatus": 0,
    "bytesSent": 0,
    "bytesReceived": 0,
    "remoteName": "connecte-esb-bat.dhl.com",
    "remoteAddr": "165.72.94.127",
    "localAddr": "165.72.1.236",
    "remotePort": "443",
    "localPort": "52842",
    "sslsubject": "/C=DE/ST=Nordrhein-Westfalen/L=Bonn/O=Deutsche Post AG/OU=ITSC/CN=connecte-esb-bat.dhl.com",
    "leg": 1,
    "timestamp": 1520235200649,
    "duration": 1099,
    "correlationId": "c0f29c5a3e484ba5419878db",
    "serviceName": "PeP e-Fulfillment API",
    "subject": "d006366e-3b9e-415f-baff-cc1eec24898a",
    "operation": "Get Available Stock",
    "type": "http",
    "finalStatus": null
  },
  {
    "_type": "http",
    "uri": "/efulfillment/v1/stock/5117855/OHK30",
    "status": 200,
    "statustext": "OK",
    "method": "GET",
    "vhost": null,
    "wafStatus": 0,
    "bytesSent": 0,
    "bytesReceived": 0,
    "remoteName": "165.72.87.12",
    "remoteAddr": "165.72.87.12",
    "localAddr": "165.72.1.236",
    "remotePort": "51946",
    "localPort": "6443",
    "sslsubject": null,
    "leg": 0,
    "timestamp": 1520235200642,
    "duration": 1107,
    "correlationId": "c0f29c5a3e484ba5419878db",
    "serviceName": "PeP e-Fulfillment API",
    "subject": "d006366e-3b9e-415f-baff-cc1eec24898a",
    "operation": "Get Available Stock",
    "type": "http",
    "finalStatus": "Pass"
  }
]

我在这里搜索了其他文章,但即使我发现它从来没有对我有用。

json jq
1个回答
2
投票

试试map(select(.finalStatus != null))

https://jqplay.org/s/CzPU5im0RE

© www.soinside.com 2019 - 2024. All rights reserved.