postman 我想根据jmeter中api响应提供的名称获取ID

g52tjvyc  于 2022-11-07  发布在  Postman
关注(0)|答案(1)|浏览(177)

我想使用JSON提取器从Jmeter中的以下响应中提取基于siteName的siteId

{
   "data":[
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f05ffda66a081998d43693252c",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":null,
         "equipName":null,
         "startTime":1655457117728,
         "endTime":1655460660602,
         "_id":"62ac455ffa26f9604b0f2216",
         "mTitle":"BATTERY LEVEL LOW FATAL",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"The battery level of your CCU Shoaib 75F CCU has dropped below 20% and is not charging. Please check that the tablet is secured to it's mount. if it is plugged in, please contact 75F support.",
         "mNotificationMsg":"The battery level of your CCU Shoaib 75F CCU has dropped below 20% and is not charging. Please check that the tablet is secured to it's mount. if it is plugged in, please contact 75F support.",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0605cc49ef8c5ea02bdf464db",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":"0538175e-06b2-40bf-b300-35f707d0aea5",
         "equipName":"Shoaib 75F-CPU-1001",
         "floorId":"1221e81b-d06c-4ce0-9da2-478e48696871",
         "floorName":"Floor1",
         "zoneId":"721f6ae7-63f6-4c35-9266-41f95b1a9304",
         "zoneName":"Zone2",
         "startTime":1655457117742,
         "endTime":1657085385220,
         "_id":"62ac455ffa26f9604b0f2217",
         "mTitle":"ZONE TEMPERATURE DEAD",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Equip Shoaib 75F-CPU-1001 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mNotificationMsg":"Equip Shoaib 75F-CPU-1001 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f060621c1018b074203fb97b3b",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":null,
         "equipName":null,
         "startTime":1652906700000,
         "endTime":1652908500000,
         "_id":"62855acfb1457725f828fb63",
         "mTitle":"CCU DISCONNECTED",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Shoaib 75F Shoaib 75F CCU(som edit) has been offline/unresponsive for more than 60 minutes",
         "mNotificationMsg":"Shoaib 75F Shoaib 75F CCU has been offline/unresponsive for more than 60 minutes",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f060621c1018b074203fb97b3b",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":null,
         "equipName":null,
         "startTime":1652996700001,
         "endTime":1655457300000,
         "_id":"6286ba60b1457725f828fddb",
         "mTitle":"CCU DISCONNECTED",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Shoaib 75F Shoaib 75F CCU(som edit) has been offline/unresponsive for more than 60 minutes",
         "mNotificationMsg":"Shoaib 75F Shoaib 75F CCU has been offline/unresponsive for more than 60 minutes",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f060621c1018b074203fb97b3b",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":null,
         "equipName":null,
         "startTime":1652913000000,
         "endTime":1652913900000,
         "_id":"6285736bb1457725f828fb72",
         "mTitle":"CCU DISCONNECTED",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Shoaib 75F Shoaib 75F CCU(som edit) has been offline/unresponsive for more than 60 minutes",
         "mNotificationMsg":"Shoaib 75F Shoaib 75F CCU has been offline/unresponsive for more than 60 minutes",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f05ffda661081998d436932527",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":"0538175e-06b2-40bf-b300-35f707d0aea5",
         "equipName":"Shoaib 75F-CPU-1001",
         "floorId":"1221e81b-d06c-4ce0-9da2-478e48696871",
         "floorName":"Floor1",
         "zoneId":"721f6ae7-63f6-4c35-9266-41f95b1a9304",
         "zoneName":"Zone2",
         "startTime":1652902897210,
         "endTime":1652903069386,
         "_id":"62854bf1b1457725f828fb5d",
         "mTitle":"BUILDING TEMP LIMIT BREACH",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"LOW",
         "mMessage":"The temperature in your zone Zone2 is 0.0 which is  currently outside the defined building limit 55.0 - 90.0",
         "mNotificationMsg":"The temperature in your zone Zone2 is 0.0 which is  currently outside the defined building limit 55.0 - 90.0",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f05ffda661081998d436932527",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":"779bfe86-7475-4996-8a46-7483e8f3f709",
         "equipName":"Shoaib 75F-hyperstatcpu-1000",
         "floorId":"1221e81b-d06c-4ce0-9da2-478e48696871",
         "floorName":"Floor1",
         "zoneId":"bed2d8eb-e68b-490e-b433-4a877d643f51",
         "zoneName":"Zone1",
         "startTime":1652902836914,
         "endTime":1652903069408,
         "_id":"62854bb5b1457725f828fb5b",
         "mTitle":"BUILDING TEMP LIMIT BREACH",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"LOW",
         "mMessage":"The temperature in your zone Zone1 is 0.0 which is  currently outside the defined building limit 55.0 - 90.0",
         "mNotificationMsg":"The temperature in your zone Zone1 is 0.0 which is  currently outside the defined building limit 55.0 - 90.0",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0605cc49ef8c5ea02bdf464db",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":"779bfe86-7475-4996-8a46-7483e8f3f709",
         "equipName":"Shoaib 75F-hyperstatcpu-1000",
         "floorId":"1221e81b-d06c-4ce0-9da2-478e48696871",
         "floorName":"Floor1",
         "zoneId":"bed2d8eb-e68b-490e-b433-4a877d643f51",
         "zoneName":"Zone1",
         "startTime":1652902836846,
         "endTime":1652903069421,
         "_id":"62854bb5b1457725f828fb5a",
         "mTitle":"ZONE TEMPERATURE DEAD",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Equip Shoaib 75F-hyperstatcpu-1000 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mNotificationMsg":"Equip Shoaib 75F-hyperstatcpu-1000 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0605cc49ef8c5ea02bdf464db",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":"0538175e-06b2-40bf-b300-35f707d0aea5",
         "equipName":"Shoaib 75F-CPU-1001",
         "floorId":"1221e81b-d06c-4ce0-9da2-478e48696871",
         "floorName":"Floor1",
         "zoneId":"721f6ae7-63f6-4c35-9266-41f95b1a9304",
         "zoneName":"Zone2",
         "startTime":1652902897185,
         "endTime":1652903069398,
         "_id":"62854bf1b1457725f828fb5c",
         "mTitle":"ZONE TEMPERATURE DEAD",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Equip Shoaib 75F-CPU-1001 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mNotificationMsg":"Equip Shoaib 75F-CPU-1001 is reporting a temperature of 0.0 outside the defined building limit 55.0 ~ 90.0",
         "mEnabled":true,
         "isFixed":true
      },
      {
         "definitionId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f060621c1018b074203fb97b3b",
         "siteId":"1e764b8d-4ef9-4421-8301-4bf4dacfb5f0",
         "siteName":"Shoaib 75F",
         "ccuId":"d5d9d77b-1421-4e23-b6e6-75c45e14dfa5",
         "ccuName":"Shoaib 75F CCU",
         "equipId":null,
         "equipName":null,
         "startTime":1652918400001,
         "endTime":1652919300001,
         "_id":"62858883b1457725f828fb7b",
         "mTitle":"CCU DISCONNECTED",
         "mAlertType":"CUSTOMER VISIBLE",
         "mSeverity":"SEVERE",
         "mMessage":"Shoaib 75F Shoaib 75F CCU(som edit) has been offline/unresponsive for more than 60 minutes",
         "mNotificationMsg":"Shoaib 75F Shoaib 75F CCU has been offline/unresponsive for more than 60 minutes",
         "mEnabled":true,
         "isFixed":true
      }
   ],
   "total":2820
}

我想获取siteName为“Shoaib 75F”的siteId。我尝试使用下面的JSON提取器,但它不起作用

$..[?(@.siteName == 'Shoaib 75F')].siteId
wj8zmpe1

wj8zmpe11#

如果您在View Results Tree监听器的JSONPath测试器模式中至少提供了以下响应数据,那么您的JsonPath表达式对我来说工作正常:

这可能是因为JSON在一个子结果中返回,所以您可能希望将JSON Extractor的“Apply to”字段切换为Main sample and sub-samples

相关问题