我有一个带有JSON数组的http响应
{"message":"SUCCESS","possibilities":
[{"type":"title","value":"Mercedes-Benz FashionWeek New York"},
{"type":"title","value":"Mercedes-Benz FashionWeek New York"},
{"type":"title","value":"Mercedes-Benz FashionWeek New York"},
{"type":"title","value":"Chicago Fire vs. New York City"},
{"type":"title","value":"New York Mets vs. Philadelphia Phillies"},
{"type":"title","value":"New York Knicks vs. Detroit Pistons"},
{"type":"title","value":"Baltimore Orioles vs. New York Yankees"},
{"type":"title","value":"New York Mets vs. Philadelphia Phillies"},
{"type":"title","value":"Tampa Bay Rays vs. New York Yankees"},
{"type":"title","value":"Tampa Bay Rays vs. New York Yankees"},]}
我需要验证没有重复的标题(在我的例子中,前3个结果是重复的)。
在Jmeter中进行此操作的最佳方法是什么?
答案 0 :(得分:1)
步骤1.使用JSONPath Extractor将所有值捕获为数组。您将使用的JsonPath表达式是$..value
这将返回一个值数组。
步骤2.使用beanshell后处理器迭代数组并检查重复项。由于您已经说明列表已经有效排序,因此您只需要对n个值进行n-1次比较。