I have below Json expression in Json Path Extractor in JMeter
$.data[0].materials[?(@.id)].reports[*].metadata['materialName','materialType']
The above expression returned as below for every 'id' in a json array
materialName1, materialType1
materialName2, materialType2
but I want to extract the value of 'id' along with 'materialName' and 'materialType' as mentioned below
id1, materialName1, materialType1
id1, materialName2, materialType2
id2, materialName3, materialType3
id2, materialName4, materialType4
etc.
please help me on this.
Thanks, Jatin
CodePudding user response:
Add JSR223 sampler and log it directly with:
log.info(variable)
Variables can be resolved in any sampler comment section with ${variable} for testing purposes.
CodePudding user response:
JMeter provides __logn() function allowing printing whatever you want to jmeter.log file
Also in case of > 1 matches returned by JSON Extractor JMeter generates the following variables
var_1=foo
var_2=bar
...
var_matchNr=2
so you will be able to print them to jmeter.log file as:
1.upto(vars.get('var_matchNr') as int, { index ->
log.info(vars.get('var_' index))
})
if you want to print to STDOUT instead - replace log.info
with println
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?