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
I am assuming that JMeter uses Java-based regular expressions... This could mean no named capturing groups. Apparently, Java7 now supports them, but that doesn't necessarily mean JMeter would. For JSON that looks like this:
{
"name":"@favorites",
"description":"Collection of my favorite places",
"list_id":4894636,
}
{
"name":"@AnotherThing",
"description":"Something to fill space",
"list_id":0048265,
}
{
"name":"@SomethingElse",
"description":"Something else as an example",
"list_id":9283641,
}
...this expression:
\{\s*"name":"((?:\\"|[^"])*)",\s*"description":"((?:\\"|[^"])*)",(?:\\}|[^}])*}
...should match 3 times, capturing the "name" value into the first capturing group, and the "description" into the second capturing group, similar to the following:
1 2
--------------- ---------------------------------------
@favorites Collection of my favorite places
@AnotherThing Something to fill space
@SomethingElse Something else as an example
Importantly, this expression supports quote escaping in the value portion (and really even in the identifier name portion as well, so that the Javascript string I said, "What is your name?"!
will be stored in JSON as AND parsed correctly as I said, \"What is your name?\"!