jqを使用したカールコマンド

jqを使用したカールコマンド

初めてカールコマンドを学ぶのにこの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'

関連情報