更新时间:2022-12-17 12:50:18
如另一个答案的注释中所述,现在空手道上有一张增强票证,可以实现此线程中讨论的内容,请参见 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