假定您具有以下格式的响应:
{ "data": { "assets": { "sadsad12dwqqwe": "asda1212312", "asdasd1213123": "asdas2131231" } }}您可以使用JSR223PostProcessor
和以下代码提取键名称:
new groovy.json.JsonSlurper().parse(prev.getResponseData()).data.assets.eachWithIndex{ def node, int idx -> log.info('Key ' + idx + '=' + node.getKey()) vars.put('key_' + idx, node.getKey())}It will print key names into jmeter.log file and create JMeter Variables
like:
- `${key_1}`- `${key_2}`- etc.holding the required “key” values.
Demo:
References:
- Apache Groovy: Parsing and producing JSON
- Apache Groovy - Why and How You Should Use It



