通过案例带你轻松玩转JMeter连载(35)(下)

简介: 通过案例带你轻松玩转JMeter连载(35)(下)

7)运行得到如下结果。


v10_1=4
v10_matchNr=1
v11_1=三只松鼠每日坚果
v11_matchNr=1
v12_1={"category":"零食","name":"黄飞鸿花生","desc":"黄飞红 麻辣花生210g*2袋 每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8}
v12_matchNr=1
v1_1=黄飞鸿花生
v1_2=良品铺子
v1_3=三只松鼠每日坚果
v1_4=百草味
v1_matchNr=4
v2_1=[{"category":"零食","name":"黄飞鸿花生","desc":"黄飞红 麻辣花生210g*2袋 每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8},{"category":"零食","name":"良品铺子","desc":"良品铺子 经典坚果礼盒8袋装/1310g食食有爱 每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0},{"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30袋 中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0},{"category":"零食","name":"百草味","desc":"百草味 休闲零食小吃整箱蛋糕办公室早餐手撕面包点心传统糕点 原味肉松饼1000g/箱","price":34.9}]
v2_2={"name":"全栈软件测试工程师宝典","author":"顾翔","price":168.0}
v2_matchNr=2
v3_1=168.0
v3_2=[28.8,108.0,149.0,34.9]
v3_matchNr=2
v4_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30袋 
中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}
v4_matchNr=1
v5_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30袋 
中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}
v5_matchNr=1
v6_1={"category":"零食","name":"黄飞鸿花生","desc":"黄飞红 麻辣花生210g*2袋 每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8}
v6_2={"category":"零食","name":"良品铺子","desc":"良品铺子 经典坚果礼盒8袋装/1310g食食有爱 每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}
v6_matchNr=2
v7_1={"category":"零食","name":"良品铺子","desc":"良品铺子 经典坚果礼盒8袋装/1310g食食有爱 每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}
v7_matchNr=1
v8_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30袋 
中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}
v8_2={"category":"零食","name":"百草味","desc":"百草味 休闲零食小吃整箱蛋糕办公室早餐手撕面包点心传统糕点 原味肉松饼1000g/箱","price":34.9}
v8_matchNr=2
v9_1={"category":"零食","name":"良品铺子","desc":"良品铺子 经典坚果礼盒8袋装/1310g食食有爱 每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}
v9_matchNr=1


8)同样将结果汇集以下。如表4所示。


表4 food.json JSON JMSPath提取器获取数据


JSON JMSPath

含义

store.food[*].name

var_1=黄飞鸿花生

var_2=良品铺子

var_3=三只松鼠每日坚果

var_4=百草味

var_matchNr=4

所有food的名称

store.*

var_1=[{"category":"零食","name":"黄飞鸿花生","desc":"黄飞红麻辣花生210g*2每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8},{"category":"零食","name":"良品铺子","desc":"良品铺子经典坚果礼盒8袋装/1310g食食有爱每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0},{"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0},{"category":"零食","name":"百草味","desc":"百草味休闲零食小吃整箱蛋糕办公室早餐手撕面包点心传统糕点原味肉松饼1000g/","price":34.9}]

var_2={"name":"全栈软件测试工程师宝典","author":"顾翔","price":168.0}

var_matchNr=2

store包含的所有分类数据

store.[book.price,food[*].price]

var_1=168.0

var_2=[28.8,108.0,149.0,34.9]

var_matchNr=2

所有商品的价格

store.food  [2]

var_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}

var_matchNr=1

标号为2food数据(从0开始)

store.food  [-2]

var_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}

var_matchNr=1

倒数第2food数据

store.food  [:2]

var_1={"category":"零食","name":"黄飞鸿花生","desc":"黄飞红麻辣花生210g*2每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8}

var_2={"category":"零食","name":"良品铺子","desc":"良品铺子经典坚果礼盒8袋装/1310g食食有爱每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}

var_matchNr=2

2food的数据

store.food  [1:2]

var_1={"category":"零食","name":"良品铺子","desc":"良品铺子经典坚果礼盒8袋装/1310g食食有爱每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}

var_matchNr=1

索引1(包括)到索引2(不包括)的food的数据

store.food  [-2:]

var_1={"category":"零食","name":"三只松鼠每日坚果","desc":"三只松鼠每日坚果 750g/30中秋送礼坚果礼盒零食大礼包儿童孕妇节日混合干果腰果夏威夷果核桃仁开心果","price":149.0}

var_2={"category":"零食","name":"百草味","desc":"百草味休闲零食小吃整箱蛋糕办公室早餐手撕面包点心传统糕点原味肉松饼1000g/","price":34.9}

var_matchNr=2

最后2food的数据

store.food  [?(@.date)]

var_1={"category":"零食","name":"良品铺子","desc":"良品铺子经典坚果礼盒8袋装/1310g食食有爱每日坚果干果休闲零食坚果炒货零食大礼包节日送礼夏威夷果核桃","date":"2022-2-4","price":108.0}

var_matchNr=1

包含date属性的数据

length(store.food  [*])

var_1=4

var_matchNr=1

所有food种类的数量

max_by(store.food,  &price).name

var_1=三只松鼠每日坚果

var_matchNr=1

价格最高的food名称

min_by(store.food,  &price)

var_1={"category":"零食","name":"黄飞鸿花生","desc":"黄飞红麻辣花生210g*2每日坚果炒货休闲网红囤货零食小吃下酒菜花生米","price":28.8}

var_matchNr=1

价格最低的food信息


最后我们对比一下JSON JMESPath Extractor与JOSN提取器。


  • 一个JOSN提取器可以通过英文分号分离的方式,提取多个变量表达式。
  • JSON JMESPath Extractor一次只可以提取一个变量,如果要提取多个变量,那么就需要添加多个JSON JMESPath Extractor。
  • JOSN提取器不支持函数,JSON JMESPath Extractor支持使用函数length()、max_by()和min_by()。
目录
相关文章
|
Java 测试技术 API
通过案例带你轻松玩转JMeter连载(49)
通过案例带你轻松玩转JMeter连载(49)
251 1
通过案例带你轻松玩转JMeter连载(49)
|
存储 Linux
通过案例带你轻松玩转JMeter连载(60)
通过案例带你轻松玩转JMeter连载(60)
179 0
通过案例带你轻松玩转JMeter连载(60)
|
算法
通过案例带你轻松玩转JMeter连载(59)
通过案例带你轻松玩转JMeter连载(59)
232 0
通过案例带你轻松玩转JMeter连载(59)
|
XML JavaScript Java
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(58)
130 0
通过案例带你轻松玩转JMeter连载(58)
通过案例带你轻松玩转JMeter连载(57)
通过案例带你轻松玩转JMeter连载(57)
128 0
通过案例带你轻松玩转JMeter连载(57)
|
存储 索引
通过案例带你轻松玩转JMeter连载(56)
通过案例带你轻松玩转JMeter连载(56)
117 0
通过案例带你轻松玩转JMeter连载(56)
|
存储 Prometheus 监控
通过案例带你轻松玩转JMeter连载(55)
通过案例带你轻松玩转JMeter连载(55)
165 0
通过案例带你轻松玩转JMeter连载(55)
|
存储 监控 数据可视化
通过案例带你轻松玩转JMeter连载(54)
通过案例带你轻松玩转JMeter连载(54)
157 0
通过案例带你轻松玩转JMeter连载(54)
|
存储 Prometheus 监控
通过案例带你轻松玩转JMeter连载(53)
通过案例带你轻松玩转JMeter连载(53)
138 0
通过案例带你轻松玩转JMeter连载(53)
|
JSON 监控 数据可视化
通过案例带你轻松玩转JMeter连载(52)
通过案例带你轻松玩转JMeter连载(52)
200 0
通过案例带你轻松玩转JMeter连载(52)