I'm using Json Path Extractor to get Json array.
This is part of my response:
{"message":"SUCCESS",
"response_list":
[
{
"event":
{
"id":"123456",
"title":"Sie7e",
"venue_name":"New York, New York, United States",
"city_name":"New York",
"country_name":"United States",
"link":"http://newyorkcity.eventful.com/venues/new-york-new-york-united-states-/123456?utm_source=apis&utm_medium=apim&utm_campaign=apic",
"geo_lat":40.7127837,
"geo_lng":-74.0059413,
"time":1430715600000},
I have 10 events which under each one I have venue_name and I need to check if all of them contains "New York" (this is a search by venue result)
In Json Path Extractor my parameters are:
Destination Variable Name: venue_name
JSONPath Expression: $..venue_name
Default Value: NOT_FOUND
My BeanShell PostProcessor code (which is completely shot in the dark):
venue_name = vars.get("venue_name");
for (int i=0 ; i<10 ; i++) {
if (!venue_name[i].contains("New York")) {
Failure = true;
FailureMessage = "YOU FAILED !!!!! venue name is = " + venue_name[i];
}
}
But I'm getting an error in my log:
2015/05/17 12:42:22 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of:
venue_name = vars.get("venue_name"); for (int i=0 ; i<10 ; i++) { . . . '' : Not an array 2015/05/17 12:42:22 WARN - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:
venue_name = vars.get("venue_name"); for (int i=0 ; i<10 ; i++) { . . . '' : Not an array
How should I correct my BeanShell code?