金牛座:从 CSV 中提取数值(无引号)到 JSON
Taurus: Pull numerical value (no quotes) from CSV into JSON
如何在不添加引号的情况下将数据从 CSV 提取到 JSON?
这是我想要生成的:
{"id" : 12345}
我有一个只允许数值的休息服务,但我无法在不添加引号的情况下从 CSV 中提取数据。
body: { "id": "${id}"}
有效,但它会在消息中添加引号 {"id" : "12345"}
body: { "id" : {id} }
returns:
Error when reading config file 'test.yml': while parsing a flow mapping
in "<unicode string>", line 34, column 13:
body: { "id": ${id} }
^
expected ',' or '}', but got '{'
in "<unicode string>", line 34, column 22:
body: { "id": ${id} }
根据documentation你需要把正文字符串放在引号里:
body: '{ "id": ${id}}'
完整示例,以防您想验证该方法:
execution:
- concurrency: 1
scenario: quick-test
scenarios:
quick-test:
requests:
- url: 'http://example.com'
jsr223:
- language: groovy
execute: before
script-text: 'vars.put("id", "12345")'
method: POST
body: '{ "id": ${id}}'
更多信息:
如何在不添加引号的情况下将数据从 CSV 提取到 JSON?
这是我想要生成的:
{"id" : 12345}
我有一个只允许数值的休息服务,但我无法在不添加引号的情况下从 CSV 中提取数据。
body: { "id": "${id}"}
有效,但它会在消息中添加引号 {"id" : "12345"}
body: { "id" : {id} }
returns:
Error when reading config file 'test.yml': while parsing a flow mapping
in "<unicode string>", line 34, column 13:
body: { "id": ${id} }
^
expected ',' or '}', but got '{'
in "<unicode string>", line 34, column 22:
body: { "id": ${id} }
根据documentation你需要把正文字符串放在引号里:
body: '{ "id": ${id}}'
完整示例,以防您想验证该方法:
execution:
- concurrency: 1
scenario: quick-test
scenarios:
quick-test:
requests:
- url: 'http://example.com'
jsr223:
- language: groovy
execute: before
script-text: 'vars.put("id", "12345")'
method: POST
body: '{ "id": ${id}}'
更多信息: