使用 jq 进行卷曲命令

使用 jq 进行卷曲命令

第一次学习curl命令,我正在使用这个jason

{
  "count": 32,
  "results": [
    {
      "@class": "SFTPServer",
      "enabled": true,
      "businessProtocol": "Raw",
      "friendlyName": "AP.CD.CLEANCLAIMS.KP.EPIC",
      "backupMessages": true,
      "maxConcurrentConnections": 100,
      "inlineProcessors": "/v1/application/exchange/190571504/inlineProcessors",
      "inlinePostProcessors": "/v1/application/exchange/190571504/inlinePostProcessors",
      "schedule": "/v1/application/exchange/190571504/schedules",
      "metadataFixedItems": {},
      "restrictConsumableFileSize": false,
      "maxConsumableFileSize": 0,
      "metatadaTemplate": {
        "defaultMetadataTemplate": "",
        "enabledByProtocol": false,
        "metadataTemplatePolicy": "NEVER",
        "priorityOverFixedAttributes": false
      },
      "addressingRules": "/v1/application/exchange/pickup/190571504/addressing",
      "useCommunityMessageDelivery": true,
      "shouldOverrideDirection": false,
      "overrideDirection": null,
      "useContentProcessing": false,
      "ediSplitterEnabled": false,
      "serviceId": null,
      "service": null,
      "pickupGroupStatus": null,
      "pickupGroup": null,
      "remoteUrl": "sftp://[email protected]:5025/upload",
      "serverSettings": "/v1/embedded/server/115530501",
      "localPort": 5025,
      "defaultUser": null,
      "alwaysConsumeFromSubdirs": true,
      "modifySftpServerDirectory": true,
      "sequenced": false,
      "sequenceTimeoutSeconds": 60,
      "url": "sftp://[email protected]:5025/upload",
      "subDirectories": "/v1/application/exchange/190571504/sftpSubDirectory",
      "encryptBackup": false,
      "@id": "190571504"
    },

这个命令正在工作:

curl -k -sS -X GET -u "1:2" "http://csc2cxn00001736.cnge/pickup?offset=0&orderBy=name" -H "accept: application/json" | jq '.results'  

然而,这个给出了一个语法错误:

$ curl -k -sS -X GET -u "1:2" "http://csc2cxn00001736.cloud.kp.org:6080/api/v1/application/exchange/pickup?offset=0&orderBy=name" -H "accept: application/json" | jq '.results.friendlyName'
jq: error (at <stdin>:0): Cannot index array with string "friendlyName" SND_B2Bi0[axway@csc2cxn00001722

答案1

用于[]寻址数组的所有元素,例如:

jq '.results[].friendlyName'

相关内容