[英]how to correlate using groovy code in jmeter?
1) In my response body comes like json format.
2) Some expected reason ,i have changed that body json to normal text using below code and working expected way
import groovy.json.*
String js = vars.get("cAccountDetails")
def data = new JsonSlurper().parseText(js)
log.info("the value is "+ data)
vars.putObject('data', data)
3) This code meaning converted json to normal text and stored in some variable thats "data"
4) so my response stored in "data" variable .
5) From "data", how can i extract **specific data** using groovy code or some other code?
import java.util.regex.*
import java.util.regex.Matcher
import java.util.regex.Pattern
def matches = (data =~ '{accountDetails=\\[(.*)\\],')
vars.putObject('matches', matches)
上述代碼用於關聯目的 {"matches" VARIABLE 將存儲提取的值}
但是上面的代碼不起作用,我該如何解決這個問題?
Thanks in advance!!
除非您分享您的cAccountDetails
變量值並指出您需要從中提取什么,否則我們無法為您提供幫助。
乍一看,你的正則表達式應該看起來有點不同,即
def matches = (data =~ /accountDetails=[(.*)],/)
更多信息:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.