Vinay Chugh
Vinay Chugh

Reputation: 1

JMeter | JSON Path Extractor Query | Unable to obtain id from JSON on the basis of two filters

I have been trying to generate a JSON query for JSON Path Extractor of JMeter to obtain all task ids where 'category' does 'not contain Docebo' and where 'userTasks' have 'completed' status marked as 'false' for the following JSON response (sub response shared here):

     {
       "user": [
         {
           "id": 3633,
           "guid": "j25c9340-dert0-1113f-wkk2-000008fdb94",
           "firstname": "abc",
           "lastname": "xyz",
           "preferredname": null,
           "active": true,
           "roleKey": 1,
           "userTags": [
             {
               "id": 12345,
               "userKey": 2323,
               "tagKey": 79
             },
             {
               "id": 12332,
               "userKey": 1233,
               "tagKey": 897
             },
            {
               "id": 12313,
               "userKey": 1233,
               "tagKey": 234
             },
             {
               "id": 12345,
               "userKey": 4321,
               "tagKey": 23
             },
             {
               "id": 139334,
               "userKey": 3633,
               "tagKey": 53
             }
           ]
         }
       ],
       "tasks": [
         {
           "id": 09876,
           "title": "Submit Performance Report",
           "description": "Test data",
           "creatorKey": 0909,
           "referenceNum": null,
           "referenceVal": null,
           "dueDate": "2023-08-10T00:00:00.000Z",
           "goLiveDate": "2023-06-18T00:00:05.147Z",
           "closeDate": "2023-09-10T00:00:00.000Z",
           "archiveDate": null,
           "highPriority": false,
           "draft": false,
           "mandatory": true,
           "additionalDetails": "",
           "verificationDetails": "",
           "estimatedDuration": null,
           "estimatedDurationLabel": "30TO60MINUTES",
           "category": "Docebo",
           "level": "Individual",
           "journeyRole": null,
           "actionType": null,
           "verificationType": null,
           "externalLink": "https://testdata.b23sosaas.com/learn/course/9018/A-000M1",
           "isExternallyManaged": true,
           "sourceSystemId": 1,
           "externalId": "5678",
           "requiresProof": false,
           "archived": false,
           "lastUpdatedByStaffAt": "2023-06-17T11:47:37.062Z",
           "lastUpdatedByStaffKey": null,
           "taskOwners": [],
           "creator": {
             "id": 12312,
             "guid": "efrerertret-fgfg-2323-dgf33-rerer343231",
             "firstname": "FIRSTNAME",
             "lastname": "LASTNAME",
             "preferredname": null,
             "active": true,
             "roleKey": 6
           },
           "taskTags": [],
           "userTasks": [
             {
               "id": UTID123456,
               "dueDate": null,
               "lastUpdatedDate": null,
               "lastUpdatedAction": null,
               "completed": false,
               "requiresProof": false,
               "additionalDetails": null,
               "approverComments": null,
               "proofOfCompletionKey": null,
               "userKey": 3003,
               "approverKey": null,
               "lastUpdatedByKey": null,
               "taskKey": 15223,
               "sourceSystemId": null,
               "externalId": "9001",
               "externalUrl": null
             }
                ]
         },
         {
           "id": 009911,
           "title": "Seminar & Seminar at Socialization Event",
           "description": "Learning Environment",
           "creatorKey": 3421,
           "referenceNum": null,
           "referenceVal": null,
           "dueDate": "2023-07-02T16:30:00.000Z",
           "goLiveDate": "2023-06-30T16:30:00.000Z",
           "closeDate": "2023-07-03T18:30:00.000Z",
           "archiveDate": null,
           "highPriority": false,
           "draft": false,
           "mandatory": true,
           "additionalDetails": "",
           "verificationDetails": "",
           "estimatedDuration": null,
           "estimatedDurationLabel": "90MINUTESORMORE",
           "category": "SEMINAR",
           "level": "Individual",
           "journeyRole": null,
           "actionType": null,
           "verificationType": null,
           "externalLink": "https://abc.seminar.com/learn/course/6262/I-007",
           "isExternallyManaged": true,
           "sourceSystemId": 1,
           "externalId": "6222 / B897JJ",
           "requiresProof": false,
           "archived": false,
           "lastUpdatedByStaffAt": "2023-06-17T11:47:40.466Z",
           "lastUpdatedByStaffKey": null,
           "taskOwners": [],
           "creator": {
             "id": 9800,
             "guid": "wew23sd2f-wejyj-2357-fg24-er3g4523fa66f",
             "firstname": "FIRSTSEMINAR",
             "lastname": "LASTSEMINAR",
             "preferredname": null,
             "active": true,
             "roleKey": 9
           },
           "taskTags": [],
           "userTasks": [
             {
               "id": 4556688,
               "dueDate": null,
               "lastUpdatedDate": null,
               "lastUpdatedAction": null,
               "completed": false,
               "requiresProof": false,
               "additionalDetails": null,
               "approverComments": null,
              "proofOfCompletionKey": null,
              "userKey": 4546,
              "approverKey": null,
              "lastUpdatedByKey": null,
              "taskKey": 122445,
              "sourceSystemId": null,
              "externalId": "4566 / B7no4J",
              "externalUrl": null
            }
          ]
        },
      ]
    }

Query which was attempted:

      $.tasks.[?(@.category =~ /(?!Docebo)(.*?)/i  && @.userTasks.[?(@.completed == 'false')])].id

I am not well versed with the JSON queries and looking for inputs to get going to have all task id which have category not containing Docebo and where userTasks are marked as false for completed.

Upvotes: 0

Views: 29

Answers (1)

Ivan G
Ivan G

Reputation: 2732

I think you need to amend your JSONPath Expression to look like:

$..tasks.*[?(!(@.category != 'Docebo') && @.userTasks.[?(@.completed == 'false')])].id

More information:

Upvotes: 0

Related Questions