我想在包含双引号的调用函数(背景)中传递参数值。我的电话是:Background:
* def userCreated = call read('classpath:create-user.feature') { name: '#(name)'}
所以电话会是{“name”:“名字是”Peter“”}我试过以下内容:
我也检查了https://github.com/intuit/karate#type-conversion,但我不知道如何定义或包含一个字符串作为包含双引号的调用函数中的参数。任何的想法?谢谢。
这只是正确的行为,为了将您的字符串保存为包含"
的JSON中的值,必须正确转义它。
逃离\
将在"
之前使用
它不会改变任何东西
* def name = ' karate is created by "Peter".'
# karate is created by "Peter".
* def callInput = {"name" : "#(name)"}
# {"name" : "karate is created by \"Peter\"."}
* print callInput.name
# karate is created by "Peter".
* match callInput.name == name
它的外部相同,只有在JSON内部,它才会被转义为String引号。