Karate框架中非字符串值的嵌入表达式显示错误。

huangapple go评论53阅读模式
英文:

Embedded expression for non-string values shows error in Karate framework

问题

我想在JSON键中使用嵌入式表达式,其中包含非字符串值,如整数和布尔值。

  • def employee1 = { fName: '#(fnameVal)', lName: '#(lnameVal)', id: #(idVal), isManger: #(isManager)}

我在这里解释的相同模式中使用了String值,但它将值传递为String。所以我只是删除了单引号,它就正常工作了。但是IntelliJ显示错误信息为“ expected”。

Karate框架中非字符串值的嵌入表达式显示错误。

英文:

I want to use embedded expressions in JSON for keys containing non-string values like Integer and Boolean.

* def employee1 = { fName: '#(fnameVal)', lName: '#(lnameVal)', id: #(idVal), isManger: #(isManager)}

I used the same pattern explained for the String value in here but it was feeding values as String. So I just removed single quotes and it worked fine. But IntelliJ shows an error as "<value> expected".

Karate框架中非字符串值的嵌入表达式显示错误。

答案1

得分: 0

使用引号是正确的做法。当Karate替代数字或布尔值时,它将删除引号。

这是嵌入式表达式的优势,您可以将它们放在一个*.json文件中,它将是有效的JSON。

英文:

Use quotes, it is the right thing to do. When Karate substitutes a number or boolean, it will remove the quotes.

This is the advantage of embedded expressions, you can put them in a *.json file and it will be valid JSON.

huangapple
  • 本文由 发表于 2023年7月5日 01:26:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76614774.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定