使用JMeter

时间:2018-05-21 20:21:56

标签: jmeter

在JSON响应中,我在不同的标记内有多个具有相同名称的字段。但是我需要从那个匹配我想要的数字的标签中取出。在下面的例子中说我想在customerPpid = 467133011时获取值“(786)402-9010”

[{ “oopId”: “110034477”, “时间戳”: “3698652681958”, “TARGETTYPE”: “TMTroubleCall”, “billAccount”: “3655732026”, “customerFormattedPhoneNumber”: “(786)505-2911”, “customerIsRequestingCallBack”:“false”,“customerPpid”:“609188407”,“acceptTime”:“03/16/2018 11:31:00”,“originator”:“DPH0GNL”,“priorityForDisplay”:“3”,“备注 “:” 测试”, “ddbKey”: “8614147890T”, “显示类型”: “锡铜”, “parentFplId”: “268224478”, “parentActualDeviceType”: “TXU”, “parentDdbKey”: “8614147890T”, “parentTroubleCoordinateX” :“863634”,“parentTroubleCoordinateY”:“459622”,“parentPreviousProtectiveDeviceStack”:“268221704,23282601,23281142”,“tellItr”:“03/16/2018 14:30:00”,“tellMode”:“N”, “ticketCallComplaints”:[{“componentId”:“1685289”,“description”:“No Current”}],“customerLanguageMenuOption”:“1”},

{ “oopId”: “114249429”, “时间戳”: “3698652636567”, “TARGETTYPE”: “TMTroubleCall”, “billAccount”: “6182150000”, “customerFormattedPhoneNumber”: “(786)402-9010”,” customerIsRequestingCallBack“:”false“,”customerPpid“:”467133011“,”acceptTime“:”03/16/2018 11:31:00“,”attachTime“:”03/16/2018 11:31:00“,”鼻祖 “:” DPH0GNL”, “priorityForDisplay”: “3”, “备注”: “测试”, “ddbKey”: “8614154820T”, “显示类型”: “锡铜”, “parentFplId”: “268224477”, “parentActualDeviceType” : “TXU”, “parentDdbKey”: “8614154820T”, “parentTroubleCoordinateX”: “864084”, “parentTroubleCoordinateY”: “459307”, “parentPreviousProtectiveDeviceStack”: “268221704,23282601,23281142”, “toldItr”:“03/16 / 2018 14:30:00“,”tellMode“:”N“,”ticketCallComplaints“:[{”componentId“:”1685289“,”description“:”No Current“},{”componentId“:”4063885“,” description“:”客户检查断路器“}],”customerLanguageMenuOption“:”1“},

我应该怎么做?

2 个答案:

答案 0 :(得分:0)

  1. 添加JSON Extractor作为返回上述JSON
  2. 的请求的子代
  3. 按如下方式配置:

    • 创建变量的名称:任何有意义的变体,即phone
    • JSON路径表达式:

      $..[?(@.customerPpid == '467133011')].customerFormattedPhoneNumber

      JMeter JSON Path Extractor

  4. 那就是它,现在您应该能够在必要时将提取的值作为${phone}访问。
  5. 演示:

    JMeter Debug JSON Path

    参考文献:

答案 1 :(得分:0)

使用以下Json路径表达式

$..[?(@.customerPpid=="467133011")].customerFormattedPhoneNumber

在请求中添加JSON提取器,如下面的屏幕截图所示

enter image description here enter image description here

请关注此Link 以获取有关提取变量的更多信息

Jmeter Json Extractor