Pulling multiple values from JSON response using RegEx Extractor

前端 未结 4 1086
情话喂你
情话喂你 2020-12-03 23:00

I\'m testing a web service that returns JSON responses and I\'d like to pull multiple values from the response. A typical response would contain multiple values in a list. F

4条回答
  •  庸人自扰
    2020-12-03 23:49

    Using Ubik Load Pack plugin for JMeter which has been donated to JMeter core and is since version 3.0 available as JSON Extractor you can do it this way with following Test Plan:

    enter image description here

    namesExtractor_ULP_JSON_PostProcessor config:

    enter image description here

    descriptionExtractor_ULP_JSON_PostProcessor config:

    enter image description here

    Loop Controller to loop over results:

    enter image description here

    Counter config:

    enter image description here

    Debug Sampler showing how to use name and description in one iteration:

    enter image description here

    And here is what you get for the following JSON:

     [{ "name":"@favorites", "description":"Collection of my favorite places", "list_id": 4894636 }, { "name":"@AnotherThing", "description":"Something to fill space", "list_id": 48265 }, { "name":"@SomethingElse", "description":"Something else as an example", "list_id":9283641 }]
    

    enter image description here

    Compared to Beanshell solution:

    • It is more "standard approach"

    • It performs much better than Beanshell code

    • It is more readable

提交回复
热议问题