3

I have the following JSON and I need to get id values for instances which do not have type = Jenkins

{
  "data": [
    {
      "id": "35002399-6fd7-40b7-b0d0-8be64e4ec09c",
      "name": "94Jenkins",
      "url": "http://127.0.0.1:8084",
      "authProvider": false,
      "siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
      "status": {
        "status": "ONLINE"
      },
      "instanceStateReady": true,
      "instanceState": {
        "@type": "InstanceStateDto",
        "version": "2.60.3"
      },
      "adminUser": "admin1",
      "hasDRConfig": false,
      "managed": true,
      "type": "JENKINS",
      "siteName": "City",
      "lastRefreshTime": "2018-04-24T09:43:01.694Z"
    },
    {
      "id": "5cd3caf6-bac1-4f07-8793-5f124b90eaf5",
      "name": "RJO",
      "url": "http://test.com",
      "authProvider": false,
      "status": {
        "status": "UNAUTHORIZED"
      },
      "instanceStateReady": true,
      "instanceState": {
        "@type": "numberOfArtifacts",
        "version": "5.5.2-m002",
        "licenses": {
          "RJO : artrjo-m": {
            "type": "ENTERPRISE",
            "validThrough": "Jun 12, 2021",
            "licensedTo": "Test",
            "licenseHash": "asdadsdb612bda1aae745bd2a3",
            "expired": false
          },
          "RJO : artrjo-s1": {
            "type": "ENTERPRISE",
            "validThrough": "Jun 12, 2021",
            "licensedTo": "JFrog",
            "licenseHash": "asaswca236350205a3798c0fa3",
            "expired": false
          }
        }
      },
      "adminUser": "jfmc",
      "hasDRConfig": false,
      "managed": false,
      "warnings": [
        "Site is missing",
        "Failed to connect to the service. Please verify that the service information provided is correct."
      ],
      "type": "ARTIFACTORY"
    },
    {
      "id": "0727a49a-6c95-433e-9fc5-7e5c760cc76f",
      "name": "NinetyTwo",
      "url": "http:127.0.0.1:8081",
      "authProvider": true,
      "siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
      "status": {
        "status": "ONLINE"
      },
      "instanceStateReady": true,
      "instanceState": {
        "@type": "numberOfArtifacts",
        "version": "5.9.0",
        "licenses": {
          "NinetyTwo": {
            "type": "ENTERPRISE",
            "validThrough": "Dec 30, 2018",
            "licensedTo": "Test",
            "licenseHash": "qweqwed95f712dbabee98184da52443",
            "expired": false
          }
        }
      },
      "adminUser": "admin",
      "hasDRConfig": false,
      "managed": true,
      "type": "ARTIFACTORY",
      "serviceId": "jfrt@01c7g4c7hq0dpd0qa71r8c09sj",
      "siteName": "Test",
      "lastRefreshTime": "2018-04-24T09:43:01.698Z"
    }
  ]
}

And I use $..[?(@.type!='JENKINS')].id path to receive id-s which relate to the instances with type NOT JENKINS, however JSON Extractor returns me the Jenkins's id too. The question is how can I receive ids for non-jenkins instances only?

1 Answer 1

2

Replace your JSON path expression with the below and it should work:

$.data.[*][?(@.type != "JENKINS")].id

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.