JMeter - How to read JSON file?

孤者浪人 提交于 2020-05-18 12:04:55

问题


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:

  1. 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
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!