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'

관련 정보