JMeter | JSON 路径提取器查询 |无法根据两个过滤器从JSON获取id

问题描述 投票:0回答:1

我一直在尝试为 JMeter 的 JSON 路径提取器生成 JSON 查询,以获取以下 JSON 中“类别”不“不包含 Docebo”且“用户任务”的“已完成”状态标记为“假”的所有任务 ID回复(此处共享子回复):

     {
       "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
            }
          ]
        },
      ]
    }

尝试查询:

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

我不太熟悉 JSON 查询并寻找输入来获取所有任务 id,这些任务 id 的类别不包含 Docebo,并且 userTasks 被标记为 false 表示已完成。

json jmeter performance-testing jmeter-5.0 blazemeter
1个回答
0
投票

我认为你需要修改你的 JSONPath 表达式,如下所示:

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

更多信息:

© www.soinside.com 2019 - 2024. All rights reserved.