JMeter-如何读取JSON文件? [英] JMeter - How to read JSON file?

查看:701
本文介绍了JMeter-如何读取JSON文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JMeter中为数据文件使用了CSV格式.我们的副总裁希望将格式更改为JSON.如何从磁盘读取JSON文件?

I used the CSV format for the data files in JMeter. Our VP wants to change the format to JSON. How can I read a JSON file from the disk?

推荐答案

您至少有2个选择:

  1. 使用 HTTP请求采样器和file协议,例如:

  1. Use HTTP Request sampler and file protocol like:

JSON文件基本上是纯文本文件,因此您可以使用 JSON提取器 JSON路径提取器来解析JSON数据并将结果存储到 JMeter变量供以后重用

JSON files are basically plain-text files so you will be able to use JSON Extractor or JSON Path Extractor to parse JSON data and store the result into JMeter Variables for later reuse

参考文献:

  • Jayway JsonPath - Getting Started
  • Advanced Usage of the JSON Path Extractor in JMeter

使用 JSR223测试元素和Groovy语言. Groovy通过 JsonSlurper 内置了JSON支持.因此您将能够以编程方式解析JSON文件.

Use JSR223 Test Elements and Groovy language. Groovy has built-in JSON support via JsonSlurper so you will be able to parse the JSON file programmatically.

参考:

  • The Groovy programming language - Parsing and producing JSON
  • Groovy - JSON

这篇关于JMeter-如何读取JSON文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆