JSON数值元素顺序

用于判断使用Jsonpath语法获取到的用例返回值中数组某元素排序是升序或降序排列。


表示使用Jsonpath语法对数组中某元素顺序进行校验,使用规则如下:

  • 参数类型为数值时,默认升序=ascending 降序=descending。如参数列输入$.data.goodsList[1:].actualCurrentPrice,值列输入ascending。则判断actualCurrentPrice值是否是升序排列。
  • 参数类型为字母时,默认升序=letter_asc 降序=letter_desc。如参数列输入$.data.goodsList[*].goodsgrade,值列输入letter_desc。则判断goodsgrade值是否是降序排列。

如校验返回值中actualCurrentPrice为升序排列,响应body为:

BODY
"{...}":
"code":200,
"msg":"OK",
"data":{
"goodsList":[
   {
   "actualCurrentPrice":19,
   "actualStorageStatus":1,
   "brandCountryName":"美国品牌",
   "discountBenefitStr":"4.9折",
   "factoryGoods":false,
   "feedbackRate":"87.5%好评",
   "goodsgrade":"B"
   },
   {
   "actualCurrentPrice":29.9,
   "actualStorageStatus":0,
   "brandCountryName":"中国品牌",
   "discountBenefitStr":"4.8折",
   "factoryGoods":true,
   "feedbackRate":"97.5%好评",
   "goodsgrade":"A"
   },
  ...
}
Copyright © GoApi 2018 all right reserved,powered by Gitbook该文件修订时间: 2023-08-24 14:34:58

results matching ""

    No results matching ""