Reputation: 31
JSON response is returned in the following format, I need to extract values from the first index of the array for example 925,88 using groovy or perhaps another language, and then store them into a variable to pass them along in the next request. Also, values need to be unique
[
[
22588,
[
925,
88
],
0,
0,
0,
null,
"moderate"
]
Any help would be appreciated!
Thanks
Upvotes: 0
Views: 1198
Reputation: 168157
Add JSR223 PostProcessor after the JSON Extractor
Put the following code into "Script" area:
def numbers = []
1.upto(vars.get('foo_matchNr') as int, { index ->
new groovy.json.JsonSlurper().parseText(vars.get('foo_' + index)).each { number ->
numbers.add(number)
}
})
vars.put('payload', new groovy.json.JsonBuilder(numbers.sort().unique()).toPrettyString())
Replace foo
with the actual JMeter Variable name you use in the JSON Extractor
Use ${payload}
where you need to send unique numbers
More information:
Upvotes: 1