且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

空手道:在javascript中将字符串转换为空手道本机变量

更新时间:2022-12-17 13:03:02

正如在另一个答案的评论中提到的,现在有一个关于空手道的增强票来实现这个线程中讨论的内容,请参阅 https://github.com/intuit/karate/issues/1202

As mentioned in the comments of another answer, there is now an enhancement ticket on karate to achieve what was discussed in this thread, see https://github.com/intuit/karate/issues/1202

在此之前,通过在 Java 中将字符串解析为 json 并将其返回给空手道,我设法获得了大部分我想要的关于 JSON 的内容.

Until that is in place, I managed to get most of what I wanted concerning JSON by parsing string to json in Java and returning that to karate.

Map<String,Object> result = new ObjectMapper().readValue(record, HashMap.class);

不确定是否可以为 xml 解决相同的问题

Not sure if the same can be worked around for xml

您可以在此处查看实际的解决方法:https://github.com/KostasKgr/karate-issues/blob/java_json_interop_v2/src/test/java/examples/consumption/consumption.feature

You can see the workaround in action here: https://github.com/KostasKgr/karate-issues/blob/java_json_interop_v2/src/test/java/examples/consumption/consumption.feature