本文需要安装的插件:
下载地址为:https://jmeter-plugins.org/wiki/JSONPathExtractor/
下载后解压以后将lib和lib/ext中的jar包放到安装目录对应位置,重启即可。
第一种:
json格式:{"code":"0","message":"成功","result":{"code":"0","message":"成功","responseData":"{\"visitToken\":\"2643a1a2-f7ef-4997-9480-b783a8a66bcb\"}","sign":null,"succ":true}}
1.正则截取token字段:visitToken\\":\\"(.*)\\
2.json串截取:
test:$.result.responseData
test2:$.visitToken
第二种
{"code": "0","message": "成功", "result": [{"bankCardId": 93327, "isMaster": 1, "bank": { "code": "0102", "name": "工商银行","isMainCard": 0 }, "bankCardNo": "6851", "mobile": "17050724837", "isSupportMaster": "1" }]}
截取bankCardId为例:
1.正则表达式:bankCardId":(.*?), "isMaster":
2.json串截取
test5:$.result[0].bankCardId
备注:如果数组内有多个元素,取第二个数组:result[1],如果数组内都想取值:result[*]