gpt4 book ai didi

karate - TypeError : karate. map is not a function - Karate

转载 作者:行者123 更新时间:2023-12-04 18:20:54 24 4
gpt4 key购买 nike

在使用 karate map 比较 XML 和 JSON 响应时,如果我在代码下方运行,我得到,TypeError: karate.map is not a function。这和我之前的question.有关

我尝试搜索类似的问题,但没有找到。

* def json = 
"""
{
"Main": {
"Cd":"ABC",
"descriptionTxt":"Sample Main",
"type":"A",
"codeType":"P",
"dt":"2018-10-15T00:00:00-05:00",
"validity":"3",
"segment":"Personal"
},
"testList":[
{
"code":"123",
"descriptionTxt":"My Description",
"categoryCd":"DUDU"
},
{
"code":"675",
"descriptionTxt":"His Description"
},
{
"code":"345",
"descriptionTxt":"Your Description",
"categoryCd":"BH"
}]
}
"""

* def xml =
"""
<ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
<ns4:Test>
<ns5:code>123</ns5:code>
<ns5:description>My Description</ns5:description>
<ns5:categoryCode>DUDU</ns5:categoryCode>
<ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
</ns4:Test>
<ns4:Test>
<ns5:code>345</ns5:code>
<ns5:description>Your Description</ns5:description>
<ns5:categoryCode>BH</ns5:categoryCode>
</ns4:Test>
<ns4:Test>
<ns5:code>675</ns5:code>
<ns5:description>His Description</ns5:description>
<ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
</ns4:Test>
</ns4:root>
"""

* def list = /xml/root/Test
* def fun = function(x){ return { code: xpath(x, '/code'), descriptionTxt: xpath(x, '/description'), categoryCd: xpath(x, '/categoryCode') } }
* def temp = karate.map(list, fun)
* print temp
* print json.testList
* match json.testList contains temp

错误响应

Caused by: javax.script.ScriptException: TypeError: karate.map is not a function in <eval> at line number 1

请帮忙!

最佳答案

很确定您使用的是旧版本的 Karate 。您确定使用的是 0.8.0 吗?

尝试升级。

如果您仍然卡住,请按照以下流程操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

关于karate - TypeError : karate. map is not a function - Karate ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53555387/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com