Jmeter读取csv文件解析json做参数化

http请求添加JSR223前置处理

import groovy.json.JsonSlurper


def filePath = 'D:/apache-jmeter-5.3/bin/New.csv'
def file = new File(filePath)
def lines = file.readLines()


lines.each { line ->
def jsonData = new JsonSlurper().parseText(line)
vars.put('account', jsonData.account)
vars.put('encryptTransmissionPassword', jsonData.encryptTransmissionPassword)
}
log.info("Account: " + jsonData.account)
log.info("Password: " + jsonData.encryptTransmissionPassword)

 
http请求体:
{
    "account": "${account}",
    "encryptTransmissionPassword": "${encryptTransmissionPassword}"
}

 

posted @ 2025-05-29 11:13  半路出家_24  阅读(90)  评论(0)    收藏  举报