简体   繁体   English

如何将 json 列表与 Gatling 中的另一个列表进行比较?

[英]How to compare json list with another list in Gatling?

I have a json response with a list of strings.我有一个带有字符串列表的 json 响应。 I want to check if it contains the same elements as some other list (order of those elements isn't important. How do I do that?我想检查它是否包含与其他列表相同的元素(这些元素的顺序并不重要。我该怎么做?

I tried this:我试过这个:

jsonPath("$.country_codes[*]").findAll.sorted.is(List("DE", "CH", "FR", "IE", "IT", "NL", "RS", "UK", "IN").sorted)

but I'm getting error "Cannot resolve symbol sorted".但我收到错误“无法解析已排序的符号”。 If I don't use 'sorted', it works, but I can't rely on getting the same order of elements from server each time..如果我不使用“排序”,它会起作用,但我不能依赖每次从服务器获取相同顺序的元素。

Use transform to turn your Seq[String] into a Set[String] or sort it.使用转换将您的Seq[String]转换为Set[String]或对其进行排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM