【发布时间】:2020-03-03 23:41:35
【问题描述】:
我正在尝试向接受项目列表的服务构建 HTTP 请求,例如:
{
"user": "john",
"table": "goods",
"articles": [
{"id": "003", "quantity": 1},
{"id": "004", "quantity": 1},
{"id": "023", "quantity": 2},
{"id": "011", "quantity": 3},
{"id": "063", "quantity": 1},
{"id": "006", "quantity": 7}
]
}
我的目标是从 CSV 文件加载所有文章,如下所示:
我想要类似的东西:
{
"user": "john",
"table": "goods",
"articles": [
{"id": "${id}", "quantity": ${qte}}
]
}
谁能帮帮我?
更新:
Dmitri T 解决了我的问题,谢谢! 我还问他如何将 JSON 对象(字典)添加到我的身体,而他回答我找到了一个解决方案,如果有人需要,我将在这里分享。如果要添加:
"user": {"id": 1, "name": "John"}
到你的正文内容,你只需要这样做:
def user = [:]
//populate user
user.put('id', 1)
user.put('name', 'John')
//add user entity to body content
content.put("user", user)
玩得开心!
【问题讨论】:
标签: jmeter