问题
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?
回答1:
You have at least 2 options:
Use HTTP Request sampler and
file
protocol like: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
References:
- Jayway JsonPath - Getting Started
- Advanced Usage of the JSON Path Extractor in JMeter
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.
References:
- The Groovy programming language - Parsing and producing JSON
- Groovy - JSON
来源:https://stackoverflow.com/questions/41561310/jmeter-how-to-read-json-file