码迷,mamicode.com
首页 > Web开发 > 详细

jmeter通过json extrcator或者正则表达式获取json返回信息

时间:2018-03-13 15:35:05      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:下载地址   wiki   space   nbsp   tab   on()   hone   cat   word   

 

1、下载地址,及插件文档资料

https://jmeter-plugins.org/wiki/JSONPathExtractor/

 

json信息如下

{
"error_code": 0,
"stu_info": [
{
"id": 5047,
"name": "lw",
"sex": "男",
"age": 28,
"addr": "陕西西安高新区32号",
"grade": "天蝎座",
"phone": "15512532946",
"gold": 1600
}
]
}

2、在http请求中添加json path extractor 或者 json extractor或者正则表达式提取器

技术分享图片

 

 

3、json 插件的配置方式及正则表达式的配置方式

技术分享图片

技术分享图片

技术分享图片

 4、查看结果

 技术分享图片

技术分享图片

 

 5、json的使用方法

{ "store": {
    "book": [ 
      { "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      { "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      { "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}
XPath JSONPath Result
/store/book/author $.store.book[*].author the authors of all books in the store
//author $..author all authors
/store/* $.store.* all things in store, which are some books and a red bicycle.
/store//price $.store..price the price of everything in the store.
//book[3] $..book[2] the third book
//book[last()] $..book[(@.length-1)]
$..book[-1:]
the last book in order.
//book[position()<3] $..book[0,1]
$..book[:2]
the first two books
//book[isbn] $..book[?(@.isbn)] filter all books with isbn number
//book[price<10] $..book[?(@.price<10)] filter all books cheapier than 10
//* $..* all Elements in XML document. All members of JSON structure.

jmeter通过json extrcator或者正则表达式获取json返回信息

标签:下载地址   wiki   space   nbsp   tab   on()   hone   cat   word   

原文地址:https://www.cnblogs.com/xinjing-jingxin/p/8554338.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!