如何在Jmeter中从此JSON响应中提取特定值?

时间:2018-01-18 08:54:57

标签: json jmeter response load-testing

{"SecureCustomerLoginFPinResult":"{\"Success\":true,\"AccountCode\":\"AC0717000251\",\"AccountId\":\"251\",\"FullName\":\"Asad\",\"LastLoginTime\":\"Jan 18, 2018, 12:16:19 PM\",\"IsFirstLogin\":\"0\",\"WalletAmount\":93982.40,\"SessionId\":\"efa02b314f\",\"ProfileImage\":\"\",\"NickName\":\"\",\"UnreadRequest\":\"1\",\"ProfileLevel\":\"0\",\"IsPinSet\":\"1\",\"LastName\":\"Akram\",\"CashDepositMinAmount\":\"100.00\",\"InviteCode\":\"https:\/\/test.keenu.pk\/keenu\/?Asad7207\",\"InvitePoints\":50,\"SignUpPoints\":40,\"KeenuCode\":\"trfhf\",\"DebitCreditFeeChargeInPercentage\":\"10.00\",\"CustomerState\":\"C\",\"BankCategoryId\":\"1\",\"IsNameVerifed\":\"False\",\"CustomerPoolBalances\":[{\"Amount\":\"83305.00\",\"CustomerPoolId\":\"499\",\"PoolId\":\"1\",\"Priority\":\"1\",\"ExpirationDate\":\"18\/01\/19\",\"AmountToBeExpire\":\"\"},{\"Amount\":\"10677.40\",\"CustomerPoolId\":\"500\",\"PoolId\":\"2\",\"Priority\":\"2\",\"ExpirationDate\":\"31\/01\/18\",\"AmountToBeExpire\":\"200.00\"}]}"}

我想要提取“SessionId'来自Jmeter中使用JSON Extractor的JSON响应。我尝试过多个路径表达但没有成功。请帮忙。 感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用Regular expression extractor使用以下配置提取SessionId值:

  • 参考名称: MyVar //保存提取值的变量名称。
  • 正则表达式: \\"SessionId\\":\\"(.*?)\\"
  • 模板: $ 1 $
  • 匹配号: 1
  • 默认值: NOT_FOUND

参考:

Using-RegEx-Regular-Expression-Extractor-with-JMeter